2 messages in com.googlegroups.bloggerdevhelp with php client| Subject: | help with php client![]() |
|---|---|
| From: | alain34 (alai...@nme.com) |
| Date: | 03/28/2006 06:14:18 AM |
| List: | com.googlegroups.bloggerdev |
Hi,
I have managed to get some example code from the developer blog, but it is not working for me. I have just look at the previous post in the group, and it seems that the person submitting in issue with his java client provide a different url than the one that I try to reach with my php client.
java snippet : URL url = new URL("https://www.blogger.com/atom/BLOGIDNUMBER");
php complete code : <?php
//Generate xml content to post along with your request. $content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; $content .= "<entry xmlns=\"http://purl.org/atom/ns#\">"; $content .= "<title mode=\"escaped\" type=\"text/plain\">I-recycle</title>"; $content .= "<issued>" . gmdate("Y-m-d\TH:i:s\Z", time()) . "</issued>"; $content .= "<generator url=\"http://www.conceputel.co.uk/\" version=\"1.0\"></generator>"; $content .= "<content type=\"text/html\">"; $content .= "<div xmlns=\"http://www.w3.org/1999/xhtml\">Test 1</div>"; $content .= "</content>"; $content .= "</entry>";
$contentLength = strlen($content); $credentials = base64_encode("myBlog:myPassword");
$data = "POST /atom HTTP/1.1\r\n"; $data .= "Authorization: Basic $credentials\r\n"; $data .= "Content-type: application/atom+xml\r\n"; $data .= "Content-length: $contentLength\r\n"; $data .= "UserAgent: myUserAgent\r\n"; $data .= "Host: www.blogger.com\r\n"; $data .= "Connection: Close\r\n\r\n"; $data .= $content;
//Step 3: //Create socket connection to blogger and post the data. // connect over SSL // http://us3.php.net/fsockopen // from the PHP manual "As of PHP 4.3.0, if you have compiled in OpenSSL // support, you may prefix the hostname with either 'ssl://' or 'tls://' // to use an SSL or TLS client connection over TCP/IP to connect to the // remote host." // $data is from step 2
$fp = fsockopen('ssl://www.blogger.com', 443, $errno, $errstr, 15); if (!$fp) { echo "$errstr ($errno)<br />\n"; } else { fputs($fp, $data); }
// for debugging/response handling you can view the data blogger responds with while(!feof($fp)) { echo fgets($fp, 1024); }
?>
the answer from the php client is : HTTP/1.1 404 Date: Tue, 28 Mar 2006 14:02:37 GMT Server: Apache Set-Cookie: JSESSIONID=456B0743278335FED9056DA4522032C7; Path=/; Secure Content-Length: 58 Connection: close Content-Type: application/xml; charset=utf-8
We're sorry but the Blog you're requesting cannot be found
Can somebody help me to figure out how I can post to the blog through my client? Also, can somebody confirm which URL should be used? If it is the one used by the java client, how can I found my BLOGIDNUMBER?
Thanks in advance for your help
Alain




