Tutorial :AuthSub and Blogger


I'm trying to retrieve a list of blogs of a given user. I think I've successivelly authorizated myself with all the token stuff, but when I ask for the list blog, I recieve a 302 moved temporarily. I'm using curl to send the requests.

In my callback page, I upgrade the token to a session token:

$header = array();  $header[] = 'GET /accounts/AuthSubSessionToken HTTP/1.1';  $header[] = 'Authorization: AuthSub token="'.$_GET['token'].'"';    $curl = curl_init('https://www.google.com/accounts/AuthSubSessionToken');  curl_setopt( $curl, CURLOPT_HTTPHEADER, $header );  curl_setopt( $curl, CURLOPT_HEADER, true );  curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true );  curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, false );  $response = curl_exec( $curl );  

I obtain this response:

HTTP/1.1 200 OK  Content-Type: text/plain; charset=UTF-8  Date: Thu, 15 Jul 2010 20:08:07 GMT  Expires: Thu, 15 Jul 2010 20:08:07 GMT  Cache-Control: private, max-age=0  X-Content-Type-Options: nosniff  X-XSS-Protection: 1; mode=block  Content-Length: 39  Server: GSE  

Ok, now I think I'm ready to data retrieval, I do this:

$headers = array();  $headers[] = 'GET /feeds/default/blogs HTTP/1.1';  $headers[] = 'Authorization: AuthSub token="'.$token.'"';  $headers[] = 'Host: www.blogger.com';    $curl = curl_init( 'http://www.blogger.com' );  curl_setopt( $curl, CURLOPT_CONNECTTIMEOUT, 5 );  curl_setopt( $curl, CURLOPT_TIMEOUT, 5 );  curl_setopt( $curl, CURLOPT_PORT, 80 );  curl_setopt( $curl, CURLOPT_HEADER, true );  curl_setopt( $curl, CURLOPT_HTTPHEADER, $headers );  curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true );  curl_setopt( $curl, CURLOPT_SSL_VERIFYHOST, false );  curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, false );  curl_setopt( $curl, CURLOPT_FOLLOWLOCATION, true );  curl_setopt( $curl, CURLOPT_MAXREDIRS, 5);  $reply = curl_exec( $curl );  

But I always receive a 302 moved temporarily. I've checked I have not enabled safe_mode nor openbasedir to allow CURLOPT_FOLLOWLOCATION work, and I also checked with

curl_getinfo( $curl, CURLINFO_EFFECTIVE_URL );  

what was the last url requested to be sure curl is trying the redirect.

Maybe I did some AuthSub step wrong?

PD: Obviously I ommited the code that extracts the session-token, but I double checked it and I grab the correct part of the header.


If you examine the output of curl_getinfo($curl);, do you get a redirect_count? If so: if it's 5 I'd set the maxredirs higher.

If not, I'd set

curl_setopt($curl,CURLOPT_VERBOSE,true);  curl_setopt($curl,CURLOPT_STDERR, STDOUT)  

... and examine it's output.

Maybe it's as simple as setting this (never worked with the blogger interface):


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »