gpt4 book ai didi

facebook - Facebook 群组可以发送动态消息吗?

转载 作者:行者123 更新时间:2023-12-02 22:03:34 28 4
gpt4 key购买 nike

我正在尝试开发一个 Facebook 应用程序,该应用程序应将新闻源发送到网站;

我设法使用 app_id 和 app_secret 进行订阅,但我没有收到新闻源;

public function actionSubscription() {
$app_id = '691036934243090';
$app_secret = 'ca6e828f41c638dba4fb0864f7d9f6e8';
$app_url = 'http://www.ghidul-comercial.ro';
$fields = 'feed';
$verify_token = 'blabla';

// Fetching an App Token
$app_token_url = 'https://graph.facebook.com/oauth/access_token?client_id='
. $app_id . '&client_secret=' . $app_secret
. '&grant_type=client_credentials';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $app_token_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$res = curl_exec($ch);
parse_str($res, $token);

if (isset($token['access_token'])) {
// Let's register a callback
$params = array(
'object'
=> 'page',
'fields'
=> $fields,
'callback_url'
// This is the endpoint that will be called when
// a User updates the location field
=> $app_url . '/index.php/site/api',
'verify_token'
=> $verify_token,
);

curl_setopt($ch, CURLOPT_URL, 'https://graph.facebook.com/'
. $app_id . '/subscriptions?access_token='
. $token['access_token']);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
$res = curl_exec($ch);
if ($res && $res != 'null') {
print_r($res);
}

// Fetch list of all callbacks
curl_setopt($ch, CURLOPT_POST, 0);
$res = curl_exec($ch);
}
if ($res && $res != 'null') {
print_r($res);
}
curl_close($ch);
error_log('test');
}

这就是我打算捕获提要的方式:

public function actionApi() {
$data = new Data();
$data->info = '1';
$data->save(false);

$method = $_SERVER['REQUEST_METHOD'];
$data = new Data();
$data->info = $method;
$data->save(false);

$rawdata1 = file_get_contents('php://input');
$rawdata2 = json_decode($HTTP_RAW_POST_DATA,true);
$rawdata2 = json_decode(file_get_contents('php://input'),true);


$data = new Data();
$data->info = $rawdata1;
$data->save(false);

if ($method == 'GET' && isset($_GET['hub_mode']) && $_GET['hub_mode'] == 'subscribe' && isset($_GET['hub_verify_token']) && $_GET['hub_verify_token'] == 'blabla') {
echo $_GET['hub_challenge'];
exit;
} elseif ($method == 'POST') {
$post = file_get_contents("php://input");
$data = new Data();
$data->info = $post;
$data->save(false);
}

$data = new Data();
$data->info = '2';
$data->save(false);
}

最佳答案

转到link单击获取访问 token ,通过单击从 3 个选项卡中选择所有内容,单击获取访问 token ,然后粘贴您的组 ID;也在您的 Feed 字段中单击“提交”。

仅此而已!这会起作用

关于facebook - Facebook 群组可以发送动态消息吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18505288/

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