我正在使用以下代码来更新facebook中的用户状态。它在2个月前工作正常。现在问题是在使用应用程序登录facebook后需要花费太多时间来加载nd错误消息就像“这样网页有一个重定向循环“。请提出让tis代码工作的想法
<?php
//include the Facebook PHP SDK
include_once 'facebook.php';
//instantiate the Facebook library with the APP ID and APP SECRET
$facebook = new Facebook(array(
'appId' =>'id',
'secret' =>'xyz',
'cookie' => true
));
$user = $facebook->getUser();
if($user) {
//do stuff when already logged in
if( session_id() )
{
} else {
session_start();
}
$access_token = $facebook->getAccessToken();
$permissions_needed = array('publish_stream', 'read_stream', 'offline_access', 'manage_pages');
foreach($permissions_needed as $perm) {
if( !isset($permissions_list['data'][0][$perm]) || $permissions_list['data'][0] $perm] ! = 1 ) {
$login_url_params = array(
'scope' => 'publish_stream,read_stream,manage_pages',
'fbconnect' => 1,
'display' => "page",
'next' => 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']
);
$login_url = $facebook->getLoginUrl($login_url_params);
header("Location: {$login_url}");
exit();
}
}
$accounts = $facebook->api(
'/me/accounts',
'GET',
array(
'access_token' => $access_token
)
);
$parameters = array(
'message' =>'hi ansari.....',
'link' =>'www.yahoo.com',
'name' =>"vijesh",
'caption' =>'',
'description' =>"mydescription"
);
$newpost = $facebook->api(
'/me/feed',
'POST',
$parameters
);
}
else
{
$login_url_params = array(
'scope' => 'publish_stream,read_stream,manage_pages',
'fbconnect' => 1,
'redirect_uri' => 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']
);
$login_url = $facebook->getLoginUrl($login_url_params);
//redirect to the login URL on facebook
header("Location: {$login_url}");
$accounts = $facebook->api(
'/me/accounts',
'GET',
array(
'access_token' => $access_token
)
);
$parameters = array(
'message' =>'Hi gud evening',
'link' =>'www.yahoo.com',
'name' =>"vijesh",
'caption' =>'my Try',
'description' =>"mydescription"
);
$newpost = $facebook->api(
'/me/feed',
'POST',
$parameters
);
exit();
}
?>
事先提前