Recieve a image in facebook bot messenger using php

564 views Asked by At

This is my sample code where I get the message from the user. It's text only, so how can I get if I receive an image from the user? I'm using PHP from my bot.

 $message = $input['entry'][0]['messaging'][0]['message']['text'];
2

There are 2 answers

0
Mavs Mavs On

get the value of attach file using php:

$message = $input['entry'][0]['messaging'][0]['message']['attachments'];

to post the result => $message[0]['payload']['url'].

0
Arbaz Siddiqui On

You will have the image url at:

entry[0].messaging[0].message.attachments[0].payload.url

To check if you have recieved a text or an image :

if(entry[0].messaging[i].message.text)
  //text
else 
  // image