Using restfb-1.6.12
Creating client as:
facebookClient = new DefaultFacebookClient(accessToken, new CustomWebRequestor(), new DefaultJsonMapper());
In CustomWebRequestor, customizeConnection() is overridden and following is specified:
connection.setChunkedStreamingMode(5242880);
Uploading video as:
facebookClient.publish("me/videos", FacebookType.class, BinaryAttachment.with(mediaFileName, mediaFileStream), Parameter.with("description", msg), Parameter.with("target_id", "me"), Parameter.with("metadata", 1));
Encountering following:
com.restfb.exception.FacebookNetworkException: A network error occurred while trying to communicate with Facebook: Facebook request failed (HTTP status code 504)
at com.restfb.DefaultFacebookClient.makeRequestAndProcessResponse(DefaultFacebookClient.java:625)
Upload happens as I can find the video on Facebook, but the reponse received from API doesn't tell me so. API works for videos of lesser size, like 400-500 MB. Recent change log doesn't mention any change around this either. Some help please.
Have you had a look at https://developers.facebook.com/docs/graph-api/reference/v2.0/user/videos#publish
There, Facebook states that
Videos must be encoded as multipart/form-data and published to
graph-video.facebook.com instead of the regular Graph API URL.
Also, other rules are
The aspect ratio of the video must be between 9x16 and 16x9, and the
video cannot exceed 1024MB or 180 minutes in length
Does RestFB use the correct endpoint?
Facebook fixed the problem under bug developers.facebook.com/bugs/791781120839901
Related
So I am trying to post an image to my personal page through the new v2 LinkedIn API. I am sending the following data:
{"author":"urn:li:person:MYID","lifecycleState":"PUBLISHED","visibility":{"com.linkedin.ugc.MemberNetworkVisibility":"PUBLIC"},"specificContent":{"com.linkedin.ugc.ShareContent":{"shareMediaCategory":"IMAGE","shareCommentary":{"text":"Hello. Just testing the LinkedIn API."},"media":[{"status":"READY","originalUrl":"https:\/\/www.bbc.co.uk\/news","title":{"text":"BBC news"},"description":{"text":"A test post about BBC news"},"media":"urn:li:digitalmediaAsset:C4E22AQFmydgog-wKTw"}]}}}
As you'll see I've already uploaded the image and have a successful Asset ID and reference.
I get a successful id back from Linkedin: urn:li:share:651159824176993XXX but for some reason my image never appears?? What am I doing wrong?
Before creating the UGC post referencing the registered asset, you need to make sure that the asset is AVAILABLE, otherwise your image won't appear on LinkedIn.
When registering an asset, it goes through the following phases:
PROCESSING (LinkedIn probably does some optimizations to the image / checks if it's valid)
AVAILABLE (you should be good to go)
CLIENT_ERROR (or some other error I can't remember. Basically you should try it with a different asset)
For my app, before creating the UGC post with the image(s), I make sure the asset(s) is / are AVAILABLE first. How do I do that? By checking the status of each asset every 5 seconds with a timeout of 5 minutes (I tried it with a GIF once and to this day is still processing haha).
Once all assets are AVAILABLE, I create the UGC post referencing them, just like you did in your question.
I've uploaded about 40k photos using the Google Photos uploader tool, and now I'm trying to get a list of those photos using the Picasa Web Albums Data API (as there is no separate Google Photos API that I'm aware of).
So far, it appears impossible to get a complete list of all of the photos because you can list only 1000 photos at a time and then use the start-index parameter to do paging, but the server returns an error once you use a start-index above 11000. With a start-index of 11000 this occurs:
gdata.photos.service.GooglePhotosException: (500, 'Internal Server Error', 'Deprecated offset is too large for a stream ID query. Please switch to using resume tokens.')
(I'm using Python, but have confirmed that the error is independent of the language library)
I'd be happy to switch to using "resume tokens" like the error indicates... except that they are not mentioned in any documentation that I could find.
This is an authenticated request and the URL I'm using looks like this:
https://picasaweb.google.com/data/feed/api/user/[myUserID]/albumid/[myAlbumID]?kind=photo&max-results=1000&start-index=11000
Can anyone show me an example request using resume tokens or point me to documentation on them? Or, if anyone knows of some other way to get a complete list of all of the photos in a large album, that'd be great too. Thanks!
EDIT: the problem happens in any language, but in Python you can reproduce it consistently with:
startIndex = 1
while 1:
print '(fetching more photos)'
photos = client.GetFeed(ALBUM_URL, limit=1000, start_index=startIndex)
for photo in photos.entry:
print 'startIndex:', startIndex
startIndex += 1
where ALBUM_URL is like the URL I listed above and client is an authenticated instance of gdata.photos.service.PhotosService.
Just sharing some information I came across while testing my application.
Facebook Graph API implements rate limiting as described on their documentation page. Today I was trying to retrieve the feed from CNN facebook page and I got the following 500 error:
{"error":{"code":1,"message":"Please reduce the amount of data you're asking for, then retry your request"}}
This is the query I was trying to test:
https://graph.facebook.com/v2.3/5550296508/feed?fields=id,actions,application,caption,created_time,description,from,icon,is_hidden,link,message,message_tags,name,object_id,picture,place,privacy,properties,source,status_type,story,story_tags,to,type,updated_time,with_tags,shares,likes.limit(50),comments.filter(stream).limit(50){attachment,created_time,from,id,like_count,message,message_tags,comments{attachment,created_time,from,id,like_count,message,message_tags}}&access_token=xxxxxxx
I tried to set different limit values to reduce the size, and eventually it worked. By inspecting the response size and playing around with it a bit, I found that the error is thrown when the response reaches (roughly) the 200k threshold.
I tested with Graph API versions 2.3 - 2.4 - 2.5 - 2.6
I found no documentation about this response size limit on the facebook APIs documentation, so it's possible that it will be changed in the future.
Just thought it might be useful to share if you are modelling something using their API.
I originally misready the error message Please reduce the amount of data you're asking for, then retry your request and assumed I was getting rate-limited -- i.e. making too many API calls in a short time period. Thanks Dieghito for your answer, which helped me realize the error is about the response size.
In my case it was fetching /comments that was exceeding the response size limit. I had the limit set to 1000, which was fine for most posts. But for posts with a lot of lengthy comments, the response size grew too large. I had paging already setup, so simply requesting fewer comments per page (limit: 50 or 100) solved the problem for me. Just posting that here for people whose problem could be related to comments.
Hi Google Drive Staff,
I have tried to stream video files from Google Drive(Without Downloading). But I gets alerts that Sign In. I have went thoroughly with Dr. Edit sample App but i did not found any solution. I tried with downloadUrl , embedLink, webContentLink, alternateLink. All gives message to sign In. When i tried with exportsLinks i get a Null Message. What is the problem Here. If U have any suggestion Please Let me Know...
I have tried with Google Drive for iOS in iPod, there we can stream Video without Downloading.
Please suggest me to resolve this issue
Thanks in Advance...
I could solve it just by appending the access_token to the download url
audiofile.strPath=[NSString stringWithFormat#"%#&access_token=%#",downloadUrl,accessToken];
pass the strPath to your avplayer object to play music.
I did not try the video part. but i think a similar approach should work.
you can fetch the access token from the GTMOAuth2Authentication object
Note that you might need to refresh it if its expires.
Hope this helps you.
Regards
Nitesh
I think it depends what you mean by "stream". Last time I looked, the download links all had a content disposition: attachment header, which instructs the browser to download rather than render the content.
If you have your own client fetching the url, you can choose to ignore that header and do what you like with the content as it is fetched. imho, it would be nice if the client could add a parameter to the url to indicate to the Google servers that it wants the content to be rendered v. downloaded, but hey ho.
You need to authorize all requests to downloadLinks with an Authorization header. Read more about the authorization and learn how to retrieve your users an access token on https://developers.google.com/drive/about-auth
I am using facebook app to upload videos to user walls.
Note:
I have user permission for publish.
Script is fine and works for small videos with success.
I have user extended token with validity 60 days and I debugged my token and its fine with validity and have posting permissions.
my script for posting is working fine with small videos.
ISSUE
When I try to upload more than 100 MB video with only 5 or 6 min length I receive following api errors.
An access token is required to request this resource.
An active access token must be used to query information about the current user.
NOTE
When I apply small videos it works successfully.
TEST
I added same video with same length with two different sizes one is 720P with ~121MB and other is 480P with ~42MB both are same video.
But 480P with ~42MB uploaded successfully and 720P with ~121MB failed and api throws this exactly error in error log
An access token is required to request this resource.
$facebook->setAccessToken($access_token);
$facebook->setFileUploadSupport(true);
$data = $facebook->api('/'.$user_id.'/videos', 'post', $args);
The issue was resolved.
We placed this as a bug in facebook bug.
We used the code provided by Facebook support team and issue was resolved.
Facebook support response:
"We were not able to replicate this issue.
If you are still experiencing issues, can you setup a testbench on your server and run the below example to verify your implementation? If you can provide a link to the testbench with the modified code below, that would be helpful in replicating this issue.
Main code:
https://github.com/eosgood/fbphpsdk
Modification for video post:
https://gist.github.com/anonymous/6872121
We tested this on our servers with a 177MB MKV video without any failures."