这是我的代码。它不适合我。它的输出未找到。有谁能告诉我。它试图找到什么。我正在使用curl。
$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;
请告诉我我错在哪里。
答案 0 :(得分:2)
你可以使用它。希望它适合你。
$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);
}
答案 1 :(得分:0)
根据此页面:https://developers.google.com/blogger/docs/3.0/using#AddingAPost您将需要标题
中的身份验证令牌Authorization: /* OAuth 2.0 token here */