Facebook群组可以发送新闻Feed吗?

时间:2013-08-29 07:59:32

标签: facebook

我正在尝试开发一个应该将新闻Feed发送到网站的fb应用程序;

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

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);
}

1 个答案:

答案 0 :(得分:2)

转到link点击Get Access Token,点击3个标签中的所有内容进行选择,点击获取帐户令牌,然后粘贴您的群组ID;也可以在您的Feed字段中单击“提交”。

这就是全部!这将有效