<?php
'require 'facebook.php';
include 'config.php';
//database connect
@mysql_connect($host,$username,$password) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());
mysql_query("SET NAMES utf8");
//Create facebook application instance.
$facebook = new Facebook(array(
'appId' => $fb_app_id,
'secret' => $fb_secret
));`$output = '';
//get users and try liking
$result = mysql_query("
SELECT
*
FROM
Likers
");
`
if($result){
while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
$m = $row['access_token'];
$facebook->setAccessToken ($m);
$id = trim($_POST ['postid']);
try {
$facebook->api("/".$id."/comments",'post',array('message' => $comment));
}
catch (FacebookApiException $e) {
$output .= "<p>'". $row['name'] . "' failed to like.</p>";
}
}
}
?>当脚本开始执行时,在10秒或15秒内正常工作并执行输出
但在一段时间后给出了500内部服务器错误
我猜这是时间限制的问题,但我同时使用了时间间隔和时间限制代码,没有发生任何事情。
发布于 2014-11-05 19:30:00
它根本不能那样工作,修复你的错误。例如:
'require 'facebook.php'; (remove that sign at the beginning)
`$output = ''; put this in a new line and remove that sign at the beginning)
$comment is not defined另外,你应该使用PDO,而不是mysql_connect。请查看PHP文档以了解这一点。
顺便说一句,看起来你想创建某种“自动生成器”或“自动注释器”。请记住,这在Facebook上是不允许的(显然)。
https://stackoverflow.com/questions/26756009
复制相似问题