是的,构建一个应用程序,它会在用户的生日愿望帖子上发表评论,但是,问题是注释图api,语句执行一次,整个应用程序崩溃了,我用echos调试了,它的同样,在一条评论之后没有代码正在执行。请帮忙
<?php
require 'src/facebook.php';
$facebook = new Facebook(array(
'appId' => '',
'secret' => ''
));
$app_url = "https://apps.facebook.com/appleappspace/";
$uid = $facebook->getUser();
?>
<html>
<head>
<body>
<?php
if(!$uid){
$params = array(
'scope' => 'user_birthday,user_friends,friends_birthday,friends_status,
read_stream,email,status_update,publish_actions',
'redirect_uri' => 'http://apps.facebook.com/appleappspace/'
);
$loginUrl = $facebook->getLoginUrl($params);
echo "<script type='text/javascript'> top.location.href = '$loginUrl';</script>";
}else if($uid){
try{
$strings = array("b'day","birthday","bday","hbd","bdae","Birthday");
echo "Successfully Logged In <br/>";
$yesterday = mktime(0,0,0,date("m"),date("d")-3,date("Y"));
$yesterday = date("Y-m-d",$yesterday);
$user_wishes = $facebook->api('/me/feed?since='.$yesterday,'GET');
$length_user_wishes = count($user_wishes['data']);
$string_length = count($strings);
for($i=0;$i<=$length_user_wishes;$i++){
for($j=0;$j<=$string_length;$j++){
if(strchr($user_wishes['data'][$i]['message'],$strings[$j]) !== FALSE){
$POST_ID = $user_wishes['data'][$i]['id'];
$comment = "Its not Working";
$facebook->api('/'.$POST_ID.'/likes','POST');
$facebook->api('/'.$POST_ID.'/comments','POST',array('message' => $comment));
// nothing executes after this statement, whole program breaks up.
}
}
}
} catch(FacebookApiException $e) {
$echo($e);
$uid = NULL;
}
}
?>
</body>
</head>
</html>