Re: php curl http header authorization in google blogger api
Madeleine Thompson <[email protected]>
| Newsgroups | gmane.comp.web.blogger.api |
|---|---|
| Message-ID | <CAGML2d=Q+XfOcUCNuEXBmcZUYO1BsLtYRjyB8sxhh25xSnWzYA@mail.gmail.com> |
It is probably easier to avoid curl and initialize a Google_Client the same way as any other Google service. For an installed application, there is an example of that for Calendar at http://stackoverflow.com/questions/10587542/google-api-unattended-reading-of-calendar-how-to-login, though it looks like the class names may be old. Once you have a Google_Client, you can get a Google_BloggerService (instead of a Google_CalendarService) from that with: $blogger_service = new Google_BloggerService($client); On Tue, Oct 29, 2013 at 3:57 AM, Giberno Morini <[email protected]>wrote: > there has few articles about google blogger api, so i have some question > about it. I have access passing OAuth 2.0, get access token like ya29., > now how to use access token, api key,user_id, to get blogger user info, blogger > user post? > > I am not find any examples use Google_BloggerService.php, so i tried use > curl code below: > > $ch = curl_init(); > curl_setopt($ch, CURLOPT_URL,"https://www.googleapis.com/blogger/v3/users/".$user_id."/blogs?key=".$api_key); > curl_setopt($ch, CURLOPT_HTTPHEADER, $header); > $header = array(); > $header[] = 'Content-length: 0'; > $header[] = 'Content-type: application/json'; > $header[] = 'Authorization:'.$access_token; > curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); > curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); > curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1); > curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); > curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); > $html = curl_exec($ch); > curl_close($ch); > echo $html; > > But always return: { "error": { "errors": [ { "domain": "global", "reason": "required", "message": "Login Required", "locationType": "header", "location": "Authorization" } ], "code": 401, "message": "Login Required" } } I have no idea how to solve it, maybe some one could help me out of this question, Thanks and regards. > > > -- > You received this message because you are subscribed to the Google Groups > "Blogger Developer Group" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/bloggerdev. > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "Blogger Developer Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/bloggerdev. For more options, visit https://groups.google.com/groups/opt_out.