How to obtain the live video id of a facebook live video?
Asked Answered
L

3

6

I am trying to access the live views count of a live video that is live through a Facebook Page. I am using the ID that I am obtaining from the API request {page-id}/videos/uploaded When I am using that video id and making a GET request of {video-id}?fields='live_views its showing error code of 100 with the message as:

(#100) Tried accessing nonexisting field (live_views) on node type (Video)

I have the following permissions:

'manage_pages', 'publish_pages', 'business_management', 'read_insights', 'user_videos'

I am making the GET request using user_access_token. I am using Graph API Version 2.8.

Please let me know if I am using the wrong ID. IF yes, then how can i get the live_video_id of a live video posted in page?

Lodgings answered 12/1, 2017 at 7:53 Comment(5)
developers.facebook.com/docs/graph-api/reference/page/…Marji
I am using the page access token and making the GET request as '{page-id}/live_videos' still its showing as insufficient permission as error.Lodgings
Seems like you need to get your app approved for the Live Video API before, developers.facebook.com/bugs/206384603102540Marji
But I am making the call through 'Graph API Explorer', by using the temporary page token generated by the explorer. I am using it for development purpose. The link that you have shared states that Admin users can have access to live_views.Lodgings
As far as I know, you can only use a user token. You can easily create it for you app with facebooks Access Token Tool: developers.facebook.com/tools/accesstokenDiaghilev
D
2

To get the live views count of a video a fan page, you need:

With this you can call graph API in the following format: https://graph.facebook.com/v2.8/<fan_page_id>/live_videos?access_token=<access_token>?fields=live_views

Of course, you may add more elements in fields parameter if you need more information. Here Facebook's Graph API explorer helps: https://developers.facebook.com/tools/explorer

When you add status to fields parameter, "LIVE" means, it's currently live, "VOD" means it has already finished.

If you try to implement a WebHook for it, let me now if it works. Thanks.

Diaghilev answered 8/2, 2017 at 16:32 Comment(4)
yeah yeah.. but do we need the LIVE_API access permission approved by Facebook in order to retrieve the {page_id}/live_videos endpoint ?Atom
As far es I see it, we don't have this permission for our app. So I guess not.Diaghilev
This seems to have changed, I just get the following message when trying, prompting the LIVE_API access permission: (#10) To use live-video-api on behalf of people who are not admins, developers and testers of your app, your use of this endpoint must be reviewed and approved by Facebook. To submit this feature for review please read our documentation on reviewable features: https://developers.facebook.com/docs/apps/reviewEquerry
As far as we see it, live_api permission is to create videos while for reading Page Public Content Access permission suffice.Diaghilev
C
2

To get live views you need to call the api with the live video id, which you get from calling, page id can initially be either the page-id or name

"https://graph.facebook.com/v10.0/${page_id}/live_videos?access_token=${access_token}
Sample response:
    {
  "title": "hello world 2",
  "status": "LIVE",
  "embed_html": "...,
  "id": "123123" // this is the live video id
},

After you have retrieved the live video id you can call this endpoint to get the live_views edge

https://graph.facebook.com/v10.0/${live_id}fields=live_views&access_token=${access_token}
sample response:
{
 "live_views": 1,
 "id": "123123"
}

Docs for endpoint 1: https://developers.facebook.com/docs/graph-api/reference/live-video/

Docs for endpoint 2: https://developers.facebook.com/docs/graph-api/reference/live-video/reactions#Reading

However I understand the confusion since live_views is not listed under the second endpoint as a reaction nor even is it a reaction, so either it a mistake in facebook docs or a mistake in the graph API, either the solution provided works.

Certainty answered 8/4, 2021 at 14:34 Comment(1)
I also found that this is the right way to do it for api version 10.0.Fruition
C
0

Yes you do need to go through an app review to get the permission for tracking streams

Certainty answered 15/4, 2021 at 13:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.