问题描述
我正在使用#unificationengine API在Facebook上发送消息.我在Facebook上注册我的APP时提供的详细信息:
I am using #unificationengine API to send message on facebook.Details I have given while registering my APP on facebook:
-
站点网址: http://localhost:3000
电子邮件地址和其他必需的详细信息
Email adress and other required details
在unificationengine API中,我逐步使用了其文档中提到的所有curl,如下所示:1.使用API密钥和密钥创建的用户2.增加了连接3.测试连接4.刷新连接5.发送消息
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 Secret2. Added connection3. test connection4. Refresh connection5. Send message
所有4个都给出了200个成功代码,但发送消息却给出了403个常见错误.
All 4 gave 200 success code but send message gives 403 fobidden error.
我为此使用的卷曲如下:
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.
我想再次提一下,我在localhost上使用了它,这可能是导致错误的原因吗?如果是这样,那么我们从中获取访问令牌的facebook graph api也应该给出此类错误.
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.
我之前曾发布过此问题,在这里我也没有找到正确的解决方案.我在此处添加了我的问题的评论中提到的Curl选项,但并没有改变事情.
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.
任何帮助将不胜感激.
错误消息:
更新以下是我在facebook graph API资源管理器中运行我/权限时得到的json:
UPDATEBelow is the json I get when I run me/permissions in facebook graph API explorer:
{
"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"
}
]
}
推荐答案
我已经解决了这个问题:
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);
}
请像这样使用您的密钥Facebook的访问令牌UNIFICATION_APP_KEY(其统一密钥)UNIFICATION_APP_SECRATE(其统一密钥)
Please use your keys likefacebook accesstokenUNIFICATION_APP_KEY (its your unification keys)UNIFICATION_APP_SECRATE (its your unification keys)
如果这行不通,请告诉我.
If this will not work then please let me know.
这篇关于发送消息时,Unification Engine API中的禁止错误403的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!