无法使用PHP在blogger中插入帖子
我正在使用以下代码在blogger中插入帖子,但我从Google收到的回复为空。我做错了什么无法使用PHP在blogger中插入帖子,php,api,curl,oauth,blogger,Php,Api,Curl,Oauth,Blogger,我正在使用以下代码在blogger中插入帖子,但我从Google收到的回复为空。我做错了什么 <?php $key = "MyKey"; $blog_id = "123456"; $url = 'https://www.googleapis.com/blogger/v3/blogs/'.$blog_id.'/posts/'; $postData = array( 'kind' => 'blogger#post', 'blog' => array('id' =
<?php
$key = "MyKey";
$blog_id = "123456";
$url = 'https://www.googleapis.com/blogger/v3/blogs/'.$blog_id.'/posts/';
$postData = array(
'kind' => 'blogger#post',
'blog' => array('id' => $blog_id),
'title' => 'This is title',
'content' => 'This is content'
);
$data_string = json_encode($postData);
$head = array();
$head[] = 'Authorization: '.$key;
$head[] = 'Content-Type: application/json';
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $head);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
$rsp = curl_exec($ch);
$results = json_decode($rsp);
var_dump($results);
?>
您在$rsp中得到了什么?我在$rsp中得到了布尔值false。如果您试图使用公共API密钥,那就是您的问题。您需要使用Oauth2。(客户端id和客户端机密验证用户)putvar_dump(curl_error($ch))
在curl\u exec
之后,返回什么?SSL证书问题:无法获取本地颁发者证书