Skip to content

Instantly share code, notes, and snippets.

@Shaked
Last active October 14, 2017 21:05
Show Gist options
  • Select an option

  • Save Shaked/484e2c59a71621583c17c1e9ccb869b6 to your computer and use it in GitHub Desktop.

Select an option

Save Shaked/484e2c59a71621583c17c1e9ccb869b6 to your computer and use it in GitHub Desktop.
How to receive Messenger API location/image
<?php
if ($message->hasAttachments()) {
$attachments = $message->getAttachments();
$location = [];
foreach ($attachments as $attachment) {
switch($attachment['type']) {
case 'location':
$lat = $attachment['payload']['coordinates']['lat'];
$long = $attachment['payload']['coordinates']['long'];
break;
case 'image':
$url = $attachment['payload']['url']
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment