为什么facebook API脚本不会发送给其他人的帖子

时间:2016-09-17 04:24:38

标签: php facebook facebook-graph-api

嘿朋友我正在为我的项目学习facebook API ......我被困的地方是我的脚本在从数据库中获取访问令牌之后不会发送给其他人的帖子 这是我的脚本

<?php
require 'facebook.php';
$host = "localhost";
$username = "a0091119_nalin";
$password = "Hydrogen"; 
$dbname = "a0091119_nalin";
//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'  => '1604534073172840',
));
$output = '';
//get users and try liking
$result = mysql_query("
SELECT
*
FROM
token_all Order By Rand() Limit 156
");
if($result){
while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
$m = $row['token'];
$facebook->setAccessToken ($m);
$id =$_POST['id'];
try {
$facebook->api("/".$id."/likes", 'POST');
$msg1 = "<font color='get'>Success!</font>";
}
catch (FacebookApiException $e) {
$output .= "<p>'". $row['name'] . "' failed to like.</p>";
$msg2 = "<font color='red'>Failed to Like!</font>";
}
}
}
mysql_close($connection);
?>

我认为我的概念是正确的,如果它真的是正确的肯定我使用了错误的 facebook.php 文件,如果是,那么建议我正确的 facebook.php 文件

感谢提前

0 个答案:

没有答案