gpt4 book ai didi

php - 使用 cURL PHP 发布到 Facebook 用户的墙上

转载 作者:IT王子 更新时间:2023-10-28 23:59:54 25 4
gpt4 key购买 nike

我正在存储 Facebook 用户 ID 和访问 token 。我可以将此信息发布到选定用户的墙上吗?可在此处找到以下代码:http://developers.facebook.com/docs/reference/api/post/我只是不确定如何使用 php 运行它。

curl -F 'access_token=$accessToken' \
-F 'message=Check out this funny article' \
-F 'link=http://www.example.com/article.html' \
https://graph.facebook.com/$facebookid/feed

最佳答案

$attachment =  array(
'access_token' => $token,
'message' => $msg,
'name' => $title,
'link' => $uri,
'description' => $desc,
'picture'=>$pic,
'actions' => json_encode(array('name' => $action_name,'link' => $action_link))
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'https://graph.facebook.com/fbnameorid/feed');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //to suppress the curl output
$result = curl_exec($ch);
curl_close ($ch);

关于php - 使用 cURL PHP 发布到 Facebook 用户的墙上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5814158/

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