我曾尝试使用Facebook API向朋友发布收视率。但它需要很长时间才能响应,并使我的网页挂起。这是我的代码。Facebook API - 花很长时间发布在朋友墙上
我通过Facebook连接获取用户信息。一旦我连接,我在会话中设置用户ID,并允许用户评价我的网页上的产品。一旦评级被提交,我发布用户评级值例如。 4.5星给用户的Facebook墙以及朋友页面。但该页面需要很长时间才能回复。有什么办法可以解决这个问题。我期待着一些事情,发布过程应该发生在后端,没有用户的通知,页面应该很快响应他。
if($user)
{
$accessToken = $facebook->getAccessToken();
$ret_obj= $facebook->api('/me/feed', 'post', array(
'access_token' =>$accessToken,
'message' => $message,
'link' => $link,
'name' => strip_tags($pagetitle),
'picture' => $picture,
'caption' => $caption,
'description' => $description,
));
$mypostid = $ret_obj['id'];
$friends = $facebook->api('/me/friends');
foreach($friends['data'] as $friend) {
$frendid = "/".$friend['id']."/feed";
$frend_return = $facebook->api($frendid, 'post', array(
'access_token' =>$accessToken,
'message' => $message,
'link' => $link,
'name' => strip_tags($pagetitle),
'picture' => $picture,
'caption' => $caption,
'description' => $description,
));
}
}
$insert = mysql_query("INSERT INTO `rating`
(
`id`,
`user_id`,
`username`,
`useremail`,
`rateformoney`,
`ratefordesign`,
`rateforperform`,
`rateforfeatures`,
`rateforquality`,
`avgrating`,
`ratingcomment`,
`recommended`,
`category`,
`product_id`,
`created_date`
)
VALUES
(
NULL,
'$usrid',
'$name',
'$email',
'$rat_price', '$rat_design', '$rat_perf', '$rat_feat', '$rat_qlt', '$avgrating',
'$rat_comment', '$recommended', '$category', '$productid', CURRENT_TIMESTAMP
)
");
header($redirect);
的帮助将Facebook的考虑我的职位为垃圾邮件。 –
有没有什么办法可以在后端运行这个异步。 –
我了解了Facebook批处理API。谢谢 –