dongshuo1856 2016-02-01 11:22
浏览 68
已采纳

Facebook访问令牌页面

My problems is how can I make access token from SDK 5 or manualy? When I generate it from explorer Grapth tools its works. But its exprires after 60 days. I want generate ir for every page load or something like what. I just want get page: new_like_count...

Here is my code using SDK 5:

// FACEBOOK PAGE LIKES
    $fb = new Facebook([
        'app_id' => config('facebook.app.id'),
        'app_secret' => config('facebook.app.secret'),
        'default_graph_version' => 'v2.5'
    ]);

    $app = new FacebookApp(
        config('facebook.app.id'),
        config('facebook.app.secret')
    );

    $request = new FacebookRequest(
        $app,
        config('facebook.access_token'),
        'GET',
        '/me/?fields=new_like_count'
    );

    $response = $fb->getClient()->sendRequest($request);

    //dd($response);
    $view['facebook_likes'] = $response->getGraphNode()['new_like_count'];

P.S. I'm new at this. So i need some help :)

  • 写回答

2条回答 默认 最新

  • douxian1895 2016-02-01 11:49
    关注

    It works:

    // FACEBOOK PAGE LIKES
        $fb = new Facebook([
            'app_id' => config('facebook.app.id'),
            'app_secret' => config('facebook.app.secret'),
            'default_graph_version' => 'v2.5'
        ]);
    
        $response = $fb->get(
            config('facebook.page.id').'/?fields=likes',
            $fb->getApp()->getAccessToken()->getValue()
        );
    
        $view['facebook_likes'] = $response->getGraphNode()['likes'];
    

    Only thing i change is from:

    config('facebook.page.id').'/?fields=new_like_count',
    

    to

    config('facebook.page.id').'/?fields=likes',
    

    I realized: access page protected content is available when user is logged in and has permissions.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料