如何使用 api v3 在博主上 post

How to post on blogger using api v3

这是我的代码。它不适合我。其输出未找到。谁能告诉我。它试图找到什么。我正在使用卷曲。

 $datas =array(
'kind' => 'blogger#post',
'blog' => array('id' => '3830391901953093498'),
'title' => 'This is title',
'content' => 'With <b>exciting</b> content...'
 );
 $data_json = json_encode($datas, JSON_HEX_QUOT + JSON_HEX_TAG + JSON_HEX_AMP +    JSON_HEX_APOS + JSON_FORCE_OBJECT);
 $dat = strlen($data_json);
 $ch = curl_init();
 curl_setopt($ch, CURLOPT_URL,'https://www.googleapis.com/blogger/v3/blogs/3830391901953093498/posts&access_token='.$sd);
curl_setopt($ch, CURLOPT_POST, $dat);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_json);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
$rep=curl_exec($ch);
curl_close($ch);

这里是 $sd 是

的访问令牌
$token = $_SESSION['token'];
$kd = json_decode($token);
 $sd = $kd->access_token;

请告诉我我哪里错了。

嗯,你可以用它。希望对你有用。

$blogger = new Google_Service_Blogger($client);
try {
$blog = $blogger->blogs->getByUrl("http://hollywood159.blogspot.in");
   // creates a post
   $mypost = new Google_Service_Blogger_Post();
   $mypost->setTitle("the title");
   $mypost->setLabels("my labels array");
   $mypost->setContent("my content");
   $blogger->posts->insert($blog->getId(), $mypost);

   }

根据此页面:https://developers.google.com/blogger/docs/3.0/using#AddingAPost 您将需要 header

中的身份验证令牌
Authorization: /* OAuth 2.0 token here */