<?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内部服务器错误
我想这是时间限制问题,但我使用了时间间隔和时间限制代码没有发生任何事情。
答案 0 :(得分:0)
它完全无法正常工作,修复错误。例如:
'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文档。
不过,看起来你想创建某种“Autoliker”或“Autocommenter”。请记住,Facebook(显然)不允许这样做。