我正在尝试从Facebook添加/删除Facebook用户。我看过几篇帖子说这是不可能的,但facebook api文档似乎认为是。
https://developers.facebook.com/docs/reference/api/app-game-groups/#invite_user
我试图将它与PHP SDK一起使用,但我没有运气。这是我的代码:
require 'facebook.php';
$facebook = new Facebook(array(
'appId' => 'APP_ID',
'secret' => 'APP_SECRET'
));
$userID = $facebook->getUser();
if ($userID) {
$logoutUrl = $facebook->getLogoutUrl();
$token_url = "https://graph.facebook.com/oauth/access_token?" .
"client_id=APP_ID" .
"&client_secret=APP_SECRET" .
"&grant_type=client_credentials";
$app_token = file_get_contents($token_url);
$app_tokenArray = explode("=", $app_token);
$app_tokenF = $app_tokenArray[1];
$facebook->setAccessToken($app_tokenF);
ECHO "$app_token<br />";
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/GROUP_ID/members/'.$userID,'DELETE');
} catch (FacebookApiException $e) {
error_log($e);
ECHO $e;
$userID = null;
}
ECHO $user_profile;
}
else {
$loginUrl = $facebook->getLoginUrl();
$loginUrl .= "&scope=user_groups,friends_groups,create_event";
ECHO "<a onclick=\"window.open('$loginUrl', '', 'width=900px, height=600px, top=20px, left=30px')\">Install App</a>";
}
该应用似乎安装正常,但当我返回它以便它执行成员删除时,我收到此错误:
OAuthException:(#3)
我尝试了几件事,我正在寻找任何见解。非常感谢您的反馈。