如何为google plus..add帖子发送CURLOPT_POSTFIELDS
值。
我能够在google plus上获得..authentication令牌..但是当我在google plus上添加帖子时..然后我收到了该错误
{
"error":{
"errors":[
{
"domain":"global",
"reason":"forbidden",
"message":"Forbidden"
}
],
"code":403,
"message":"Forbidden"
}
}
发送数据
{
"object":{
"originalContent":"Happy weekend!"
},
"access":{
"items":[
{
"type":"domain"
}
],
"domainRestricted":true
}
}
代码:
$url = 'https://www.googleapis.com/plusDomains/v1/people/' . $user_id . '/activities';
$headers = array(
'Authorization : Bearer ' . $accesstoken,
'Content-Type : application/json',
'Accept : application/json',
);
$post_data = array("object" => array("originalContent" => "Happy weekend!"), "access" => array("items" => array(array("type" => "domain")),"domainRestricted" => true));
//$post_data = array("message" => "Shareing Message to your account will be here");
///$post_data['newcontent'] = "Post on Google Plus Test By Me";
echo $data_string = json_encode($post_data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url);
$file_result = curl_exec($ch);
print_r($file_result);
curl_close($ch);
答案 0 :(得分:0)
此问题可能有两种原因:
如果您要向Google+社交媒体网站发帖,您可以立即停止,因为无法做到这一点。