简体   繁体   English

发送消息时,Unification Engine API中的禁止错误403

[英]Forbidden error 403 in Unification Engine API while sending message

I am using #unificationengine API to send message on facebook. 我正在使用#unificationengine API在Facebook上发送消息。 Details I have given while registering my APP on facebook: 我在Facebook上注册我的APP时提供的详细信息:

  1. site url : http://localhost:3000 网站网址: http:// localhost:3000

  2. Email adress and other required details 电子邮件地址和其他必需的详细信息

In unificationengine API I have used all the curls mentioned in their documentation step by step as follows: 1. Created user using API key and Secret 2. Added connection 3. test connection 4. Refresh connection 5. Send message 在unificationengine API中,我逐步使用了其文档中提到的所有curl,如下所示:1.使用API​​密钥和密钥创建了用户2.添加了连接3.测试连接4.刷新连接5.发送消息

All 4 gave 200 success code but send message gives 403 fobidden error. 所有4个都给出了200个成功代码,但发送消息却给出了403错误。

The curl I am using for this is as below: 我为此使用的卷曲如下:

  $post_msg = json_encode(
        array(
            'message' =>
                array(
                    'receivers' =>
                        array(
                                array(
                                    'name'      => 'Me',
                                    'address'   => 'https://graph.facebook.com/v2.5/me/feed',
                                    'Connector' => 'facebook'

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

                            ),
                        ),
                    ),

                )
            );



    $ch = curl_init('https://apiv2.unificationengine.com/v2/message/send');
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_VERBOSE, true);
    curl_setopt($ch, CURLOPT_USERPWD,'3f43c37b-a066-4cc4-a3be-33faf72d6a21:2722fc72d-5d347-4a3a-a82b-0c1ss51aafb4');
    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];

I am trying to figure this. 我试图弄清楚这一点。 But no success. 但是没有成功。

Again I like to mention that I am using this on localhost, could that be the reason for forbidden error? 再说一遍,我想在本地主机上使用它,这可能是导致错误的原因吗? If so then facebook graph api from which we get access token should also give such error. 如果是这样,那么我们从中获取访问令牌的facebook graph api也应该给出此类错误。

Earlier I have posted this question , here also I didn't find right solution. 早些时候我发布了这个问题 ,在这里我也没有找到正确的解决方案。 I added Curl options that is mentioned in comment of my question there but it didn't changed the things. 我在此处添加了我的问题的评论中提到的Curl选项,但并没有改变事情。

Any help would be highly appreciated. 任何帮助将不胜感激。

Error Message: 错误信息:

{\\"Status\\":{\\"facebook\\":{\\"status\\":403,\\"info\\":\\"Forbidden: \\"}},\\"URIs\\":[]} {\\“状态\\”:{\\“ facebook \\”:{\\“状态\\”:403,\\“信息\\”:\\“禁止访问:\\”}},\\“ URIs \\”:[]}

UPDATE Below is the json I get when I run me/permissions in facebook graph API explorer: 更新以下是我在facebook graph API资源管理器中运行我/权限时得到的json:

{
  "data": [
    {
      "permission": "user_birthday",
      "status": "granted"
    },
    {
      "permission": "user_about_me",
      "status": "granted"
    },
    {
      "permission": "user_status",
      "status": "granted"
    },
    {
      "permission": "user_posts",
      "status": "granted"
    },
    {
      "permission": "email",
      "status": "granted"
    },
    {
      "permission": "manage_pages",
      "status": "granted"
    },
    {
      "permission": "publish_actions",
      "status": "granted"
    },
    {
      "permission": "public_profile",
      "status": "granted"
    }
  ]
}

Can you please confirm if the "Connector" name that you have given is correct? 您能否确认您输入的“连接器”名称正确吗?

While I tried your sample code that you provided, I could sent the message to facebook via UE. 当我尝试您提供的示例代码时,我可以通过UE将消息发送到Facebook。

Can you please provide the exact error message that is returned while you execute the command? 您能否提供执行命令时返回的确切错误消息?

I have resolved this problem: 我已经解决了这个问题:

public function facebookSharing($access_token) {
        $app = new UEApp(env('UNIFICATION_APP_KEY'), env('UNIFICATION_APP_SECRATE'));
        $user = new UEUser('unification_userkey', 'unification_usersecret');
        $connection = $user->add_connection('FACEBOOK', "facebook", $access_token);
        $options = array(
            "receivers" => array(
                array(
                    "name"=> "Me"
                )
            ),
            "message"=>array(
                "subject"=>'testing',
                "body"=> 'description',
                "image"=> 'use any image url',
                "link"=>array(
                    "uri"=> 'any web site url',
                    "description"=> "",
                    "title"=>"Title"
                )
            )
        );
        $uris = $connection->send_message($options);
    }

Please use your keys like facebook accesstoken UNIFICATION_APP_KEY (its your unification keys) UNIFICATION_APP_SECRATE (its your unification keys) 请使用您的密钥,例如facebook accesstoken的UNIFICATION_APP_KEY(其统一密钥)UNIFICATION_APP_SECRATE(其统一密钥)

If this will not work then please let me know. 如果无法解决问题,请告诉我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM