首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >facebook图形api访问令牌错误

facebook图形api访问令牌错误
EN

Stack Overflow用户
提问于 2017-01-06 11:45:18
回答 1查看 2K关注 0票数 0

我使用基于#unificationengine API的以下curl代码访问facebook图形api并在facebook上发布消息:

代码语言:javascript
复制
$post_msg = json_encode(
        array(
            'message' =>
                array(
                    'receivers' =>
                        array(
                                array(
                                    'name'      => 'Me',
                                    'address'   => 'https://graph.facebook.com/v2.5/7/feed?access_token='.$request->access_token,
                                    'Connector' => 'facebook'

                                ),
                        ),
                        'sender'    =>
                        array('address' => 'sender address'),
                        'subject'   => 'Hello',
                        'parts'     =>
                        array(
                                array(
                                    'id'          => '1',
                                    'contentType' => 'text/plain',
                                    'data'        => 'Hi welcome to UE',
                                    'size'        => 100,
                                    'sort'        => 0

                            ),
                        ),
                    ),

                )
            );



    $ch = curl_init('https://apiv2.unificationengine.com/v2/message/send');
    curl_setopt($ch, CURLOPT_USERPWD, "ab33333222b-acb5-49a6-a766-80d991daff41:43433232-33cb-49f0-3333-3fe6c46acb5f");
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
     curl_setopt($ch, CURLOPT_VERBOSE, true); 
    curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_msg);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);




    // execute!
    $response = curl_exec($ch);

    // close the connection, release resources used
    curl_close($ch);

    // do anything you want with your response
    var_dump($response);



    return ['label' =>$response];

代码498的访问令牌错误无效。我参考了许多关于这个话题的帖子,但不知道缺少了什么。

如何检查facebook访问令牌的有效性。

参考了以下问题:

  1. SO question 1
  2. SO question 2
EN

回答 1

Stack Overflow用户

发布于 2017-01-07 09:27:23

facebook访问令牌的生命周期约为两个小时。对于更长寿的web应用程序,特别是服务器端,需要生成长寿命的令牌。长寿的代币一般持续60天左右。

UE具有刷新facebook令牌的能力。在使用"apiv2.unificationengine.com/v2/connection/add";api调用添加连接之后,您应该调用"apiv2.unificationengine.com/v2/connection/refresh";api来使短寿命令牌变为长寿命令牌。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41505014

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档