[英]Facebook api post via “my application name”
I have facebook application that posts to its users timeline as status update. 我有Facebook应用程序,该应用程序将状态更新发布到其用户时间轴。 I am using the code below to initiate and post the message to all users, but my issue is the post "via name" on all mobile devices (iphone & BB, Samsung). 我正在使用下面的代码初始化消息并将其发布给所有用户,但是我的问题是在所有移动设备(iPhone和BB,三星)上发布了“通过名称”。
The post appears on feed wall as if the user posted it himself not the application. 该帖子显示在提要墙上,就像用户自己张贴而不是应用程序一样。
<?PHP
require_once '../scripts/config.php';
require_once '../inc/facebook.php';
$facebook = new Facebook(array(
'appId' => $fb_app_id,
'secret' => $fb_secret,
'cookie' => 'true',
));
$dbh = new PDO('mysql:dbname='.$db_name.';host='.$db_host.';charset=utf8', $db_username, $db_password );
$dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sqlid = "SELECT SQL_CALC_FOUND_ROWS * FROM offline_access_users";
$sqlmsg = "SELECT message FROM fb_messages WHERE msg_id = (SELECT MAX(msg_id) FROM fb_messages WHERE sent = 'No')";
try {
$userid = $dbh->prepare($sqlid);
$userid->execute();
$id = $userid->fetchAll(PDO::FETCH_COLUMN, 1);
$msg = $dbh->prepare($sqlmsg);
$msg->execute();
$txt = $msg->fetchColumn();
}
catch(PDOException $e)
{
echo $e->getMessage();
die();
}
$counter = 0;
foreach($id as $fbid){
$counter++;
$body = array(
'access_token' => $access_token,
'app_id' => $fb_app_id,
'from' => $fb_app_id,
'message' => $txt,
'display' => "touch",
'redirect_uri' => "http://mydomain.com",
'link' => "",
'picture' => "",
'name' => "",
'caption' => "",
'description' => "",
);
$batchPost=array();
$batchPost[] = array('method' => 'POST', 'relative_url' => "/".$fbid."/feed", 'body' => http_build_query($body));
try {
$multiPostResponse = $facebook->api('?batch='.urlencode(json_encode($batchPost)), 'POST');
$poststs = "Sent Successfully";
}
catch(FacebookApiException $e){
echo $e->getMessage();
error_log($e);
die();
}
}
unset($batchPost);
$dbh = null;
What $access_token are you using? 您正在使用什么$ access_token? where did the you generate the $access_token?Which $access_token
are you using? 您在哪里生成了$ access_token?您使用的是哪个$access_token
?
The creator of the post (the via...) is whoever created that $access_token
- the "from" will always be the owner of the Facebook account regardless of what you place there. 帖子的创建者(“ via” ...)是创建$access_token
-“ from”将始终是Facebook帐户的所有者,无论您在此处放置什么。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.