[英]Facebook SDK 5 php: “Graph returned an error: Unsupported post request.”
[英]'Unsupported delete request.' removing photo tags via Facebook PHP SDK 4
我有以下代码,并尝试在照片中将自己取消标记。
use Facebook\FacebookSession;
use Facebook\FacebookRequest;
use Facebook\GraphUser;
use Facebook\FacebookRequestException;
FacebookSession::setDefaultApplication('<appid>','<appsecret>');
$session = new FacebookSession('<my access token>');
$request = new FacebookRequest(
$session,
'DELETE',
'/<id of photo im tagged in>/tags',
array (
'id' => '<my fb id>',
)
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
/* handle the result */
var_dump($response);
var_dump($graphObject);
我同时拥有我正在使用的访问令牌的user_photos
和publish_actions
权限(如删除照片标签所要求的那样)。
但是,当我运行上面的命令时,出现此错误:
Fatal error: Uncaught exception 'Facebook\FacebookAuthorizationException' with message 'Unsupported delete request.'
我已经尝试完全按照文档中的步骤进行操作,但是我无法弄清楚自己在做错什么,为什么会得到这个。
我该怎么做才能使其正常工作?
删除标签的正确方法是调用:
$request = new FacebookRequest(
$session,
'DELETE',
'/<id of photo im tagged in>/tags',
array (
'tag_uid' => '<my fb id>',
)
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
但是,这是不正确的文档。 此外,只有列入白名单的应用程序才能通过API删除标签。 该文档也未能包含此内容。 如果您的应用未列入白名单,则会看到以下错误:
{“ error”:{“ message”:“(#3)应用程序无法进行此API调用。”,“ type”:“ OAuthException”,“ code”:3}}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.