fbsamples / live-comments-teleprompter

Example code shows how to retrieve comments and reactions for a Facebook Live video.
Other
88 stars 34 forks source link

URL Not recognized for manual posts. #9

Closed bikr closed 6 years ago

bikr commented 6 years ago

Getting a popup error: Your URL was not recognized. Please post a URL to a specific post on Facebook.

Whenever I paste a FB post URL. Here are some of the examples of urls I've tried, some of which I can actually see as "most recent" already in the prompter itself.

This one shows up in the prompter as a "recent" post of mine, but manually get error. https://www.facebook.com/bikrdotnet/posts/10160326215030724

This one is a video in a group I own. https://www.facebook.com/groups/lularoeatthestudio/permalink/1975228342805110/

This one is a right click "copy video link" from the same video. https://www.facebook.com/bikrdotnet/videos/10160346101325724/?t=12

Here is one from a page of mine, it was a Live video, which shows up while I'm live but once the video is posted and no longer live it disappears from the list of recent posts on that page in the prompter. https://www.facebook.com/groups/lularoeatthestudio/permalink/1975599382768006/

Am I selecting the link wrong somehow?

bradisbell commented 6 years ago

Loading by URL is a bit of a hack. There is no proper Facebook API for taking a URL to an object and getting object information from it. The Live Comments Teleprompter naively parses the URL for a couple common formats and attempts to look up the post or video from there.

In the cases where your URL starts with a username, /bikrdotnet, the Facebook Graph API doesn't allow loading details by username so this fails. (It works as one of your recent posts, since you've authorized the app... the app knows your numeric ID.)

For the other two, I suspect the permalink format isn't in the naive parsing at the moment, so an enhancement must be made to support them.

bradisbell commented 6 years ago

@bikr For your last permalink, https://www.facebook.com/groups/lularoeatthestudio/permalink/1975599382768006/, the link is actually to a share of a video, not the video itself. If you mouse over the date for the video within the share, right click, and copy the URL, you'll get https://www.facebook.com/LuLaRoeAtTheStudio/videos/437747239981451/ which does work with the teleprompter.

Since the video belongs to LuLaRoeAtTheStudio, the teleprompter is able to look up the numeric ID for LuLaroeAtTheStudio and concatenate that to the video ID of 437747239981451, which then becomes a full valid ID which we can query comments for.

The other permalink, https://www.facebook.com/groups/lularoeatthestudio/permalink/1975228342805110/, works differently. While this is the link directly to the video, and 1975228342805110 is the ID of that video, lularoeatthestudio is not the creator of the video, bikrdotnet is. Two problems then occur. The teleprompter tries to use the ID for lularoeatthestudio, which is the wrong ID. Even if we were able to fix that, we cannot look up the ID for your username bikrdotnet with the Graph API:

{
  "error": {
    "message": "(#803) Cannot query users by their username (bikrdotnet)",
    "type": "OAuthException",
    "code": 803,
  }
}

Therefore, we wouldn't be able to load this video. The reason we're able to load your personal videos is that we know your ID since you logged into the app.

One workaround might be to store a small Map of IDs that we know for names, and put yours in it when you log in. Then, if it is your video on the group that you're trying to load, we could know your ID from your login already. Even with that, proper group support would need to be implemented to know that it's your video and not the group's.

For last issue:

it was a Live video, which shows up while I'm live but once the video is posted and no longer live it disappears from the list of recent posts

Did the post ever re-appear again in your list of recent posts? Facebook Live videos go through transitions of state once they are not live, and I'm wondering if this problem was transitory, or a symptom of something else.

bikr commented 6 years ago

Thank you for the reply! Love the in depth breakdown, very helpful!

My live videos from my page aren't showing up at all in prompter for some reason. I'm trying to work out why. I will do some tests and see what's happening this evening.

bradisbell commented 6 years ago

I'm going to close this for now, in favor of #8. Please open up a new issue for videos from your page not showing up, if you can see any errors or anything when you check it later. Thanks.