Graph API not returning total_video_views - facebook-graph-api

Tried the following endpoints:
https://graph.facebook.com/v2.6/{video-id}/video_insights/total_video_views?access_token={token}
https://graph.facebook.com/v2.6/{video-id}/video_insights?access_token={token-id}&metric=total_video_views
But I still getting no data results in both endpoints:
{
"data": [
]
}
And my videos has some views (visualizações):
Thanks in advance.

I'm gonna paste the words from the API documentation below, but I think, since it's a video, you're calling to the wrong site.
"Host URL
Almost all requests are passed to the graph.facebook.com host URL. The single exception is video uploads, which use graph-video.facebook.com."
And here's a link to the page:
https://developers.facebook.com/docs/graph-api/overview/#structure

I had the same problem it's because you don't use the token from the page the video was published.
https://graph.facebook.com/v2.6/{video-id}/video_insights/total_video_views

Related

Autodesk Data Management API 403-Error

I am trying to receive data via Autodesk Data Management API. So far I've created an Forge-App and connected it with a BIM360 Integration.
Then I wanted to get a list of all hubs, but when I do so, I receive an JSON-Object which contains a warning:
warnings: [{
"AboutLink":null,
"Detail":""You don't have permission to access this API",
"ErrorCode": "BIM360DM_ERROR",
"HttpStatusCode": "403",
...
}]
I called the webservice via AJAX wich looks like that:
this.getToken(function(token) {
$.ajax({
url: "https://developer.api.autodesk.com/project/v1/hubs",
beforeSend: function(xhr) {
xhr.setRequestHeader("Authorization", "Bearer "+token);
}
}).done(...);
The token is a 3-legged one. I am not sure which API I do not have permission for because I am pretty sure, that I have permission for BIM360.(I created the Integration as an administrator).
In addition to was ZHong mentioned, I would suggest you try this sample. It will ask you to provision your Forge Client ID under your BIM 360 settings, just follow the steps that the app will present.
On both 2- or 3-legged, the app accessing the data (Forge Client ID) needs authorization from the account admin. Without that, the Hubs endpoint will not return your BIM 360 hub, and inside that, the sample applies for Projects endpoint.
Does everything else work fine? For example, can you get all the hubs successfully? I just verified on my side, and I can see the response including the same warning as you mentioned, but the hubs are listed correctly, and you can get the projects/items/versions without problem. I pasted my postman response as follow.
If you check the blog https://forge.autodesk.com/blog/tutorial-using-curl-3-legged-authentication-bim-360-docs-upload, it also has the same warning, but seems no impact to the following operation. I am not exactly sure what the warning means, l will check and update the details, but so far, it seems you can ignore it for now.

Read stream from Facebook Live Videos

I would like create a server to create subtitles for live videos on Facebook. I use Google Speech to convert sound to text. However, in order to do that, I need to read the facebook live streams.
Using Facebook Live API, with me/live_videos, I get the following response:
{
"status": "LIVE",
"stream_url": "rtmp://rtmp-api.facebook.com:80/rtmp/{id}",
"secure_stream_url": "rtmps://rtmp-api.facebook.com:443/rtmp/{id},
"embed_html": "<iframe src=\"https://www.facebook.com/video/embed?video_id={video_id}\" width=\"400\" height=\"400\" frameborder=\"0\"></iframe>",
"id": "{id}"
},
How can I read the streams from the above links?
I figure out that there is no way to get the current stream from Facebook now. Maybe they should add this feature to their API.
You can get the stream of ongoing live which you can play using any Dash Player.
To get the stream URL of Live Video, follow these steps:
Use the LIVE_ID of video (not Video_ID) to make the request.
Send a get request at this end point /LIVE_ID with fields as 'access_token' and 'dash_preview_url'.
This will return the URL of the ongoing live stream which can be played using any DASH Player.
You can refer to official documentation for more information.

Can there be an error in data that causes a graph to give a warning?

When I use the graph api to get public data from pages, I get for some pages a warning and other pages work fine.
The warning is: file_get_contents(http://graph.facebook.com/318993554879922) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request in ....
When I look at the data of this company in the graph tool on Facebook, I can see everything I need. Everything look fine
How can I prevent this (or better: what advice can I give to the page owbers whose data I want to show on my website to change)?
I used to think that it was a setting in the profile picture because all pages that went wrong had a "custom" setting. That setting could not be changed. But I asked a page owner to upload a new picture and the problem stayed.
It's because the request is unsupported.
{
"error": {
"message": "Unsupported get request.",
"type": "GraphMethodException",
"code": 100
}
}
So the API will return an HTTP 400 response to you.
It's either this object doesn't exist, was deleted or is a bug.

RestFB - Picture URL is not properly formatted

I'm trying to publish a post on my facebook page using RestFB.
My code is as follows:
FacebookType publishResponse = facebookClient.publish(pageId + "/feed", FacebookType.class,
Parameter.with("message", message),
Parameter.with("picture", picture),
Parameter.with("link", link),
Parameter.with("description", description));
And my parameters have the following values:
message: Test+test+test
picture: https%3A%2F%2Fcom-smallteaser-local-photo.s3.amazonaws.com%2Fskydivemag%25232fdefcfa-c7b2-4c0d-8504-9942ccd9a4b0%2523648%25230%25232592%25232592%2523292%2523292
link: http%3A%2F%2Flocalhost%3A9000%2Farticle%2F20130503-test-test-test
description: This+is+just+a+test
I am getting the exception:
FacebookOAuthException: Received Facebook error response of type OAuthException: (#100) picture URL is not properly formatted]
I read here that i can add a picture with just providing an URL and it specifically says that it is meant for 'App developers who host their images on Amazon S3 or a similar service'.
Any idea what i'm doing wrong?
I think it’s not actually the “formatting” of the picture URL, but the content it returns:
https://com-smallteaser-local-photo.s3.amazonaws.com/skydivemag%232fdefcfa-c7b2-4c0d-8504-9942ccd9a4b0%23648%230%232592%232592%23292%23292
is delivered with a Content-Type: application/octet-stream response header (as you can see here) – and that might make Facebooks scraper think that this is not really an image resource.
So you will have to figure out how configure your hosting space to deliver these images with a correct Content-Type, for example img/jpeg or img/png.
I got this problem, but only on older Android devices, not on a desktop. I could see in the server logs that there was a difference:
When accessing the URL on a desktop, Facebook does request the picture URL.
When accessing the URL on an older Android device, Facebook does not request the picture URL.
It turned out that I was using window.location.origin in constructing the absolute URL, which according to http://www.hyperink.com/blog/?p=18 only works on Webkit. It was solved by replacing, as the post suggests,
window.location.origin
by
window.location.protocol + “//” + window.location.hostname

Secure Browsing Method of Getting Facebook Photos Using APIs

Using the facebook graph you can get photo information as follows:
https://graph.facebook.com/20531316728
However the link they provide to actually grab the photos are not secure and use http:
http://profile.ak.fbcdn.net/hprofile-ak-snc4/174597_20531316728_2866555_s.jpg
Replacing http with https doesn't do the trick because you get a security warning:
https://profile.ak.fbcdn.net/hprofile-ak-snc4/174597_20531316728_2866555_s.jpg
Facebook is insisting that all apps use secure browsing and use https. However my app uses facebook photos, which cannot be accessed because they begin with http.
Does anyone know how to get around this problem?
I found the answer to my own question. You can add a parameter to get a the ssl parameter:
https://graph.facebook.com/20531316728&return_ssl_resources=1
I've never come across a way to ask the API for valid https versions of the images other than for profile pictures. That is done by https://graph.facebook.com/{userId/Name}/picture
Here's Zuck: https://graph.facebook.com/4/picture and https://graph.facebook.com/zuck/picture
If you're using the PHP SDK, this was a F***ing life-saver (where $album['cover_photo'] is the id of a photo):
$this->facebook->api($album['cover_photo'],'GET',array('return_ssl_resources'=>1));
Whenever i would simply add &return_ssl_resources=1 to the end of the query itself my server would throw a 500 error. I found another thread that showed that you can pass this argument in an array.