pimax / fb-messenger-php

Facebook Messenger Bot PHP API
GNU General Public License v2.0
314 stars 147 forks source link

Can't send local file #142

Closed mrigo closed 5 years ago

mrigo commented 6 years ago

Hi folks! I'm losing my mind trying to figure out how to send a file from local. I've try to use the ImageMessage like this: $imageMessage = new ImageMessage($this->fbUser->psui, $filePath);

But I've always this error:

(#100) Failed to fetch the file from the url

Maybe because in the ImageMessage.php file at line 71 there is an error. $attachment->setPayload(array('url' => basename($this->text)));

Maybe must be $attachment->setPayload(array('is_reusable' => $this->is_reusable )); (but the is_reusable parameters don't exists).

Even changing that line I've always have this error: (#100) Incorrect number of files uploaded. Must upload exactly one file.

This is the data I'm posting:

array ( 'recipient' => array ( 'id' => 'XXX', ), 'notification_type' => 'REGULAR', 'messaging_type' => 'RESPONSE', 'message' => array ( 'attachment' => array ( 'type' => 'image', 'payload' => array ( 'is_reusable' => false, ), ), ), 'filedata' => CURLFile::__set_state(array( 'name' => '/tmp/filename.jpeg', 'mime' => 'image/jpeg', 'postname' => 'filename.jpeg', )), )

The file exists and have 777 as permissions.

Any idea?

Thanks! \m

Yiidiir commented 6 years ago

Did you try with a file with less than 2MB ?

mrigo commented 6 years ago

Yes, I've tried with a 400KB file :)

wittfabian commented 5 years ago

Is this ticket still relevant?

mrigo commented 5 years ago

I haven't tried to see if the bug is still to fix, but I don't need it anymore thanks :)