Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VideoMessage #169

Open
Yggdrasills opened this issue Apr 10, 2019 · 13 comments
Open

VideoMessage #169

Yggdrasills opened this issue Apr 10, 2019 · 13 comments

Comments

@Yggdrasills
Copy link

Yggdrasills commented Apr 10, 2019

I'm sorry, it is my first issue on GitHub. I can't send video to the chat from my profile or youtube. Can you help me?

Here is my code:

$bot->send(new VideoMessage($message['sender']['id'], "https://youtu.be/_PBlykN4KIY"));

But it works with photos

$bot->send(new ImageMessage($message['sender']['id'], "imagepath"));

@o2-web
Copy link
Contributor

o2-web commented Apr 11, 2019

@Yggdrasills
you need to provide a link to the video file, not to the page

to get a link to a video file from youtube, I use this api https://api.unblockvideos.com/youtube_downloader?id=_PBlykN4KIY&selector=mp4

@Yggdrasills
Copy link
Author

@Yggdrasills
you need to provide a link to the video file, not to the page

to get a link to a video file, I use this api https://api.unblockvideos.com/youtube_downloader?id=_PBlykN4KIY&selector=mp4

I tried to use this link, but it doesn't work https://www.facebook.com/100035197906425/videos/116234242893172/.mp4

@o2-web
Copy link
Contributor

o2-web commented Apr 11, 2019

https://www.facebook.com/100035197906425/videos/116234242893172/.mp4
this is also a link to an html page, not a video file

@Yggdrasills
Copy link
Author

Yggdrasills commented Apr 11, 2019

https://www.facebook.com/100035197906425/videos/116234242893172/.mp4
this is also a link to an html page, not a video file

Should this work?
$bot->send(new VideoMessage($message['sender']['id'], "https://api.unblockvideos.com/youtube_downloader?id=_PBlykN4KIY&selector=mp4"));

I tried it, but it did not work

@o2-web
Copy link
Contributor

o2-web commented Apr 11, 2019

https://www.facebook.com/100035197906425/videos/116234242893172/.mp4
this is also a link to an html page, not a video file

Should this work?
$bot->send(new VideoMessage($message['sender']['id'], "https://api.unblockvideos.com/youtube_downloader?id=_PBlykN4KIY&selector=mp4"));

I tried it, but it did not work

this should not work, this is an api for getting a link to a file by ID video from YouTube

@Yggdrasills
Copy link
Author

Yggdrasills commented Apr 12, 2019

https://www.facebook.com/100035197906425/videos/116234242893172/.mp4
this is also a link to an html page, not a video file

Should this work?
$bot->send(new VideoMessage($message['sender']['id'], "https://api.unblockvideos.com/youtube_downloader?id=_PBlykN4KIY&selector=mp4"));
I tried it, but it did not work

this should not work, this is an api for getting a link to a file by ID video from YouTube

Thanks, it helped. However, when the video is sent, the bot starts spamming without stopping

$bot->send(new VideoMessage($message['sender']['id'], "correct link"));

How to fix it?

After removing the video sending line, the bot still continues spamming until I restart the server

@wittfabian
Copy link
Contributor

What do you mean with "starts spamming"?
What type of messages?

Please provide examples!

@jason-engage
Copy link
Contributor

You're probably responding to the ECHO message (which is then creating a loop). Gotta filter that out!

@Yggdrasills
Copy link
Author

Yggdrasills commented Apr 12, 2019

What do you mean with "starts spamming"?
What type of messages?

Please provide examples!

https://prntscr.com/nawlhu
https://prntscr.com/nawlkd
https://prntscr.com/nawm7a

@wittfabian
Copy link
Contributor

Check: https://github.com/pimax/fb-messenger-php-example/blob/master/index.php#L68

@Yggdrasills
Copy link
Author

Yggdrasills commented Apr 12, 2019

Check: https://github.com/pimax/fb-messenger-php-example/blob/master/index.php#L68

Did not help. Can I somehow send the video from my account by id?
https://prntscr.com/nawvfe
switch ($command) {
case 'video':
$bot->send(new VideoMessage($message['sender']['id'], "https://scontent-arn2-2.xx.fbcdn.net/v/t39.24130-6/57065986_419305962231452_3763318846007767803_n.mp4?_nc_cat=103&efg=eyJxZV9ncm91cHMiOlsidW5tdXRlZCJdLCJ2ZW5jb2RlX3RhZyI6Im9lcF9oZCJ9&_nc_ht=scontent-arn2-2.xx&oh=0514643a069fbed5a4bc74153e4ebc05&oe=5D4D13F5"));
break;

@Yggdrasills
Copy link
Author

Yggdrasills commented Apr 14, 2019

Replies to one message about 10 times. If I send something else when sending a video, then it is sent multiple times. What if the script scrolls many times? die () and exit () don't help. The server itself sends many requests to the script. Sending pictures via ImageMessage everything works as it should, but not with VideoMessage ...

@o2-web
Copy link
Contributor

o2-web commented Apr 14, 2019

Replies to one message about 10 times. If I send something else when sending a video, then it is sent multiple times. What if the script scrolls many times? die () and exit () don't help. The server itself sends many requests to the script. Sending pictures via ImageMessage everything works as it should, but not with VideoMessage ...

understood. This is because Facebook is waiting for a response and if there is no response within a few seconds then it sends the request again. The send (Video) function takes a few seconds to process.

I solved this problem this way. On any webhook message I immediately respond response 200 ok and put the processing in the queue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants