skip to Main Content

i’m trying to send a image attachment to a facebook chat with curl.
I got the instructions form (https://developers.facebook.com/docs/messenger-platform/send-api-reference/image-attachment)

curl  
-F 'recipient={"id":"YYYY"}' 
-F 'message={"attachment":{"type":"image", "payload":{}}' 
-F 'filedata=@/home/dominic/site/drophere/hitcat.jpg;type=image/jpeg' 
"https://graph.facebook.com/v2.6/me/messages?access_token=XXXX"

after I ececuted it, this error message appear:

{"error":{"message":"(#100) Message cannot be empty, must provide valid attachment or text","type":"OAuthException","code":100,"error_subcode":2018034,"fbtrace_id":"DwlBQTqXCw/"}}

cant find my mistake.

2

Answers


  1. You seem to be missing a } after “payload”:{}}. Your code should read:

    curl  
    -F 'recipient={"id":"YYYY"}' 
    -F 'message={"attachment":{"type":"image", "payload":{}}}' 
    -F 'filedata=@/home/dominic/site/drophere/hitcat.jpg;type=image/jpeg' 
    "https://graph.facebook.com/v2.6/me/messages?access_token=XXXX"
    
    Login or Signup to reply.
  2. Also their documentation has a bad JSON example here https://developers.facebook.com/docs/messenger-platform/send-messages

    curl  
      -F 'recipient={"id":"<PSID>"}' 
      -F 'message={"attachment":{"type":"<ASSET_TYPE>", "payload":{"is_reusable"=true}}}' 
      -F 'filedata=@/tmp/shirt.png;type=image/png' 
      "https://graph.facebook.com/v2.6/me/messages?access_token=<PAGE_ACCESS_TOKEN>"
    

    Note the EQUALS sign here:

    {“is_reusable”=true}

    Here should be : instead of =

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search