gpt4 book ai didi

php - Facebook API : Get a row from MySQL and Like an Object

转载 作者:行者123 更新时间:2023-11-29 00:28:38 24 4
gpt4 key购买 nike

好吧,我要制作一个 Facebook MySQL 和 PHP 项目,但我收到一个错误,我不知道它是什么有一个页面和一个输入(文本)用户输入和 facebook Post 的 id,用户点击提交按钮,该按钮通过 jQuery 将数据发送到 like_object.php,其代码为:

<?php
require 'facebooksdk/facebook.php';
$id = trim($_POST ['postid']);

if(empty($id)){
die("forbidden");
} else {
$token = $_GET["accesstoken"];

include('config.php');

//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
W3
");

if($result){
while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
$m = $row['access_token'];
$facebook->setAccessToken ($m);

try {
$facebook->api("/$id/likes", 'POST');
$msg1 = "<div class='alert alert-info'><strong>Success</strong></div>";
} catch (FacebookApiException $e) {
$output .= "<p>'". $row['name'] . "' failed to like.</p>";
$msg2 = "<font color='red'>Failed to Like!</font>";
}
}
}
mysql_close($result,$connection);
}
?>

我检查了错误日志(Facebook SDK 生成的)

[16-Jul-2013 15:25:29] PHP Warning:  Wrong parameter count for mysql_close() in /home/like_object.php on line 43

[16-Jul-2013 15:27:24] PHP Parse error: syntax error, unexpected T_VARIABLE in /home/like_object.php on line 33

那么我的php哪里出错了?

最佳答案

trim($_POST ['postid']); 

需要

trim($_POST['postid']); 

$msg1 = "
<div class='alert alert-info'><strong>Success</strong></div>
";

需要

$msg1 = "<div class='alert alert-info'><strong>Success</strong></div>";

mysql_close($result,$connection);

需要

mysql_close($connection);

此外,mysql 已弃用。请查看mysqli

$facebook->setAccessToken ($m);

需要

$facebook->setAccessToken($m);

关于php - Facebook API : Get a row from MySQL and Like an Object,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17686063/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com