sscarpa / google-api-php-client

Automatically exported from code.google.com/p/google-api-php-client
Apache License 2.0
0 stars 0 forks source link

I can not post content in blogger #200

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. I request Authorization key , web service response to me is 
http://localhost/oauth2callback?code=4/BXONDjuPV7TKfmCpSnHTD3EughoJ.on6-GO3zz_kR
XE-sT2ZLcbQdIqFLdAI
Q: I can use 
"code=4/BXONDjuPV7TKfmCpSnHTD3EughoJ.on6-GO3zz_kRXE-sT2ZLcbQdIqFLdAI" for post 
content rigth?

2. please show script for post content to blogger 
this my script:
$data = array("content"=>"2222", "title"=>"oh yes!!");
$data_string = json_encode($data);

//$ch = curl_init('http://api.local/rest/users');                               

$ch = curl_init();                                                              

curl_setopt($ch, 
CURLOPT_URL,'https://www.googleapis.com/blogger/v3/blogs/1799468368184724449/pos
ts?fields=author&key=AIzaSyDmCyR31XSqwrh_69rrG0gVm2dIvbEPk8s');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                

curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);                             

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                 

curl_setopt($ch, CURLOPT_POST, $data_string);                                   

curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                     

    'Content-Type: application/json',
//    'Authorization: Bearer 
ya29.AHES6ZQu0ie9U75v71sExxwSkTNM1TKS8G-_sgLEazudVMbQ',
    'Authorization: Bearer '.$_GET['code'],
    'X-JavaScript-User-Agent:  Google APIs Explorer',                                                                                
    'Content-Length: ' . strlen($data_string))                                  
);     

Original issue reported on code.google.com by songjab...@gmail.com on 3 Oct 2012 at 8:52

GoogleCodeExporter commented 8 years ago
You need to exchange the code for a token first. See the authenticate method of 
the client library.

Original comment by ianbar...@google.com on 22 Mar 2013 at 3:45