gpt4 book ai didi

php - Facebook Graph API - 如何使用新行发布到墙上?

转载 作者:可可西里 更新时间:2023-10-31 23:59:22 27 4
gpt4 key购买 nike

我正在玩 Facebook Graph API,但我遇到了一个问题 - 我无法找到任何方法来使用一些 HTML 代码 新行发布到墙上。怎么做到的?这是我的代码

<?php
include_once 'lib/facebook.php';
define("FACEBOOK_APP_ID", '10126');
define("FACEBOOK_API_KEY", '064ca1988b');
define("FACEBOOK_SECRET_KEY", '9afdf92114');
define("FACEBOOK_CANVAS_URL", 'http://apps.facebook.com/my_canv_app/');
if (isset($_GET['code'])){
header("Location: " . FACEBOOK_CANVAS_URL);
exit;
}

$facebook = new Facebook(array('appId' => FACEBOOK_APP_ID, 'secret' => FACEBOOK_SECRET_KEY));
$user = $facebook->getUser();
$loginUrl = $facebook->getLoginUrl(
array(
'scope' => 'email,publish_stream,user_birthday,user_location,user_about_me,user_hometown'
)
);

if (!$user) {
echo "<script type='text/javascript'>top.location.href = '$loginUrl';</script>";
exit;
}


try {
$uid = $facebook->getUser();
$me = $facebook->api('/me');
$statusUpdate = $facebook->api('/me/feed', 'post', array('message'=> 'Trying to make new line here \n <br /> Neither works', 'cb' => ''));
} catch (FacebookApiException $e) {
echo "<script type='text/javascript'>top.location.href = '$loginUrl';</script>";
}
?>

我该怎么做?

最佳答案

这有效。

try {
$uid = $facebook->getUser();
$me = $facebook->api('/me');
$statusUpdate = $facebook->api('/me/feed', 'post', array('message'=> 'Line 1
Line 2
Line 3
Line 4',
'cb' => ''));

关于php - Facebook Graph API - 如何使用新行发布到墙上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6376644/

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