Facebook api を使用して、友達全員の評価を投稿しようとしました。しかし、応答に時間がかかり、Web ページがハングします。これが私のコードです。
I am getting the user info through Facebook connect. once i connected , i set the user id in the session and allowing the user to rate the product on my page. once the rating is submitted , i am posting the user rating values eg. 4.5 stars to the user's Facebook wall and also on the friends page. but the page is taking a long to respond back. Is there any way to work out this. i am expecting some thing like , the posting process should happen in the back end without the user notice and the page should respond to him very fast.
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);