我需要通过Facebook GraphAPI发送一些图像。这些图片存储在Google Cloud Storage中,并且通过url签名公开了一天。这些签名的URL被GraphAPI拒绝。
我尝试了我所说的使用签名的URL(签名的URL由Node JS Google Cloud Storage模块生成),并且我还使用了公共可用的URL:“ https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRoQNaSq-nblLXEF07OdExu-WOiXXmWy2JTz2tWjQ5SCL1jiMxOpQ&s”错误,并已正确发布到Facebook Messenger对话中。
我正在使用模块request-promise与带有NodeJS的GraphAPI进行交互。这是请求的代码:
const request_body = {
recipient: {
id: 'a facebookID goes here'
},message: JSON.stringify({
metadata: `{ "messageUUID": "a uuid goes here","fileID": "a fileID goes here","fileContentType": "a content type goes here"}`,attachment: {
type: 'image',payload: {
is_reusable: true,url: 'a url goes here'
}
},});
};
let options = {
uri: 'https://graph.facebook.com/v5.0/me/messages',qs: { access_token: 'an access token goes hete' },method: 'POST',json: request_body
};
当URL是来自Google Cloud Storage的SignedURl时,这是我得到的错误:
StatusCodeError: 400 - {"error":{"message":"(#100) Upload attachment failure.","type":"OAuthException","code":100,"error_subcode":2018047}}
如果该URL是公开可用的URL,则图像会正确上传,并且可以在Facebook Messenger对话中看到。
我不知道该怎么办。有人得到了东西吗?