Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Facebook graph api 试图发布到我的墙上,得到;许可不足“;错误_Facebook Graph Api - Fatal编程技术网

Facebook graph api 试图发布到我的墙上,得到;许可不足“;错误

Facebook graph api 试图发布到我的墙上,得到;许可不足“;错误,facebook-graph-api,Facebook Graph Api,我正在使用以下代码发布到我的时间线。我得到了一个错误,显示在这篇文章的结尾。有什么想法吗 <?php ...... $request = 'https://graph.facebook.com/oauth/access_token'; $grant_type = 'client_credentials'; $client_id = '1504901xxxxxxxx'; //FaceBook Developer App_id LIVE $client_secret = 'xxxxxxxx

我正在使用以下代码发布到我的时间线。我得到了一个错误,显示在这篇文章的结尾。有什么想法吗

<?php
......
$request = 'https://graph.facebook.com/oauth/access_token';
$grant_type = 'client_credentials';

$client_id = '1504901xxxxxxxx'; //FaceBook Developer App_id  LIVE
$client_secret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';  //Facebook Developer Api_secret LIVE

$postargs = 'grant_type=' . urlencode($grant_type) . '&client_id=' . $client_id . '&client_secret=' . $client_secret;

curl_setopt($session, CURLOPT_POST, true);
curl_setopt($session, CURLOPT_POSTFIELDS, $postargs);
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($session);
preg_match('/access_token=(.*)/', $response, $match);
curl_close($session);

$access_token = trim($match[1]);
$Application = 'WTSO';
$User = '1504901xxxxxxxx'; /*this is the user id*/
$target_id = '1647886xxxxxxxx';

$api_url = 'https://api.facebook.com/method/stream.publish?';
$server_loc = 'https://wtso.com';
$logo = new stdClass();
$attachment = new stdClass();
$logo->type = 'image';
$logo->src = 'http://admin.wtso.com' . '/images/' . (($new_products['image_name']) ? $new_products['image_name'] : 'xx1235.jpg');
$logo->href = $facebook_bitly;
$attachment->name = ' '; //'WTSO Product Notification';
$attachment->caption = (!empty($new_products['products_short_description'])) ?    substr(strip_tags($new_products['products_short_description']), 0, 900) : $facebookText;
$attachment->description = '   ';
$attachment->href = $facebook_bitly;
$attachment->media = array($logo);

$message = (!empty($facebookText)) ? strip_tags($facebookText) : $new_products['products_name'];
$postargs2 = 'message=' . urlencode($message) . '&attachment=' . urlencode(json_encode($attachment)) . '&target_id=' . urlencode($target_id) . '&access_token=' . urlencode($access_token) . '&method=stream.publish'; 
$request2 = $api_url . $postargs2;

//Initiating a 2nd Curl instance
$session2 = curl_init($request2);
curl_setopt($session2, CURLOPT_HEADER, false);
curl_setopt($session2, CURLOPT_RETURNTRANSFER, true);
$response2 = curl_exec($session2);
curl_close($session2);
?>

我从Facebook上得到的$response2错误

<error_code>200</error_code>
<error_msg>Insufficient permission to post to target on behalf of the viewer</error_msg>
200
权限不足,无法代表查看器发布到目标

我强烈建议您使用PHP SDK,而不是使用cURL和过时的端点来拼凑这些东西……除此之外,您还可以获得一个应用程序访问令牌。为了能够使用该应用程序代表用户发布,该用户必须在之前授予该应用程序的发布权限–是这样吗…?用户确实授予了权限。我是用户。我将看一看PHP SDK,因为Facebbok最近进行了维护,所以我也有同样的问题