You can download the attachment sent to your device using webhook.
This function will only working on device with all feature package.
Special note : any autoreply feature won't work if you are using webhook.
<?php
header('Content-Type: application/json; charset=utf-8');
$json = file_get_contents('php://input');
$data = json_decode($json, true);
$device = $data['device'];
$sender = $data['sender'];
$message = $data['message'];
$text= $data['text']; //button text
$member= $data['member']; //group member who send the message
$name = $data['name'];
$location = $data['location'];
//data below will only received by device with all feature package
//start
$url = $data['url'];
$filename = $data['filename'];
$extension= $data['extension'];
//save the file
if($url){
file_put_contents("fonnte-file.$extension", file_get_contents($url));
}
//end
If your attachment have message with it, you can find it in the $message.
The attachment will be downloaded and saved in the same path as your webhook url.
To save somewhere else, determine the path where the attachment should be saved.
Note: The attachment will follow file limitation rules. if you are receiving an attachment outside file limitation rules, you will not receive it on your webhook.