Using the using the Facebook Graph API/SDK for iOS I'm getting the users News Feed with https://graph.facebook.com/me/home. Some of the news feed items return a "story":"xxx" in the JSON response, if the stories contain an image it will be accompanied by a "picture" element. The picture element always returns the small image size.
Here is an example:
"id":"100000238965505_364153823602580",
"from":{
"name":"Cristine Candelaria",
"id":"100000238965505"
},
"story":"Cristine Candelaria was tagged in Arielen Magno Bismar's photo.",
"picture":"http:\/\/photos-g.ak.fbcdn.net\/hphotos-ak-snc7\/431768_2610303545476_1491618385_31927362_2089838362_s.jpg",
"link":"http:\/\/www.facebook.com\/photo.php?fbid=2610303545476&set=at.2610291065164.2111576.1491618385.100000238965505&type=1",
"icon":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/v1\/yz\/r\/StEh3RhPvjk.gif",
"type":"photo",
"object_id":"2610303545476",
"application":{
"name":"Photos",
"id":"2305272732"
}
I've tried using what Facebook recommends in the API https://graph.facebook.com/2610303545476/picture, however this always returns a false in the JSON response and I've also tried just getting the feed details via [Graph API URL]/100000238965505_364153823602580 (sorry I can only post 2 hyperlinks). This does not yield any extra usefully information.
I've discovered that if you manipulated the end of the "photo" element URL and simply switch the _s to _n you will get the normal image size.
My question is what's the proper way to get the image and the text associated with that image (ex: first time at the super bowl...) for a News Feed using the Graph API?
Related
I have sent a request to Microsoft Graph, to get the photo from the user.
It looks like this --GET https://graph.microsoft.com/v1.0/users/USER_ID/photo/$value
I get, as a response, binary format of an image, and as doc suggests I made blob object,
like this.
Type od data(from image) that I recieve, I set to be ng.HttpPromise.
I get url, that I set for image src (in html), but photo isn't showing, and I don't have any Error popped up.
To get a user's photo using Graph, use: https://graph.microsoft.com/v1.0/users/{id | userPrincipalName}/photo/$value.
From the sample shared(see below) I can see a minor mistake:
Once the response completes, you need to call data.blob() which returns a promise containing the blob, which you can then pass to createObjectUrl after resolution.
this.videoEventServie.getPersonPhoto(contact).then(data => {
return data.blob();
}).then(function(currentBlob){
var src= URL.createObjectURL(currentBlob);
myImage.photoUrl = src;
});
Please see this answer: Using JavaScript to display a Blob for additional context.
I can't seem to get the embedded URL in a status, for example, in id=780804331608109057 -
https://twitter.com/i/web/status/780804331608109057
When I retrieve this via GET /statuses/:id, with include_entities set to true, the response looks like this:
"text":"Here\u2019s WSJ \"An Underwhelming Trump-Clinton Debate\u201d trying to spin this as something other than a Clinton triumph\u2026 https:\/\/t.co\/dpkmphGI8k",
"truncated":true,
"entities":
{"hashtags":[],"symbols":[],"user_mentions":[],"urls":
[{"url":"https:\/\/t.co\/dpkmphGI8k",
"expanded_url":"https:\/\/twitter.com\/i\/web\/status\/780804331608109057",
"display_url":"twitter.com\/i\/web\/status\/7\u2026","indices":[114,137]}]},
"source":"\u003ca href=\"https:\/\/about.twitter.com\/products\/tweetdeck\"rel=\"nofollow\"\u003eTweetDeck\u003c\/a\u003e",....
When viewed on my web client, the status instead displays the link to WSJ (referred through t.co) What I would like is one or both of these URLs to show up in my API response:
https://pbs.twimg.com/media/CtX5Sz8WIAAm4tq.jpg
what would be the short URL that looks like "t.co" followed by "/HJs4kbmTKz" (I have to break this up so SO doesn't complain.)
What am I doing wrong here?
The incredibly fast response from a staffer on the TwitterCommunity website was most gratifying:
You need to use tweet_mode=extended for the new longer Tweet format.
Ref: https://twittercommunity.com/t/missing-media-property-in-entities/70388/4
A search on this new parameter yields the appropriate documentation on dev.twitter.com - more documentation links on this mode probably exist out there. The most significant change appears to be that the key text is no longer used in non-compatibility mode - that's where the status text is, and unless you turn on compatibility mode, you have to now use the key full_text
https://dev.twitter.com/overview/api/upcoming-changes-to-tweets
I am using the Facebook Graph API to get the news feed of a user.
My request URL is:
xxxxxxxxxxxxxx/feed?fields=from,id,created_time,picture,link,object_id,message, likes.fields(id)
With the object_id, I want to get the big picture of the post, using the following url:
http://graph.facebook.com/OBJECT_ID/picture?type=normal
The picture return field is always filled, but the object_id is not being returned at some posts. Why is this? I really need the high res picture, and didn't find another way to acquire this..
The object_id is only returned if the attachment is a facebook object (e.g. an image uploaded by the user). Some stories in feed don't have a picture at all, and some pictures are not facebook objects (e.g. thumbnails for shared links).
Sometimes Facebook keeps a thumbnail of an image and stores an external link to the larger version of the image in the URL returned by the graph request. In order to access the images in either case, I used the code below, where smallURL is the URL returned by the graph request:
private String getRealURL(String smallURL){
if (smallURL.contains("url=http")){
String[] pieces = smallURL.split("url=");
pieces[1].replace("%2F", "//");
pieces[1].replace("%3A", ":");
return pieces[1];
}
else{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.setLength(0);
stringBuilder.append("http://graph.facebook.com/");
stringBuilder.append(item.getObjectID());
stringBuilder.append("/picture?type=large");
return stringBuilder.toString();
}
}
I also noticed that some FB posts didn't have {object_id} for large photos, but realized that the {picture} thumbnail URL contains the encoded URL of the original larger image:
https://external.xx.fbcdn.net/safe_image.php?d=AQBe9UvGd0vPbAHP&w=130&h=130&url=http%3A%2F%2Fskift.com%2Fwp-content%2Fuploads%2F2015%2F12%2Fpollution.jpg&cfs=1
--> contains -->
http://skift.com/wp-content/uploads/2015/12/pollution.jpg
So I check for {object_id}, and if not then try to extract the original URL from {picture}:
if(isset($post['object_id'])) {
echo "http://graph.facebook.com/".$post['object_id']."/picture";
}
elseif(isset($post['picture'])) {
echo urldecode(preg_replace('/&cfs.*/', '', preg_replace('/.*url=/', '', $post['picture'])));
}
else {
echo "no_large_image";
}
Using the YouTube API, how can I fetch structured data about a video? For instance, given a video that is a movie trailer, how can I find the movie title or topic in a structured format, and other interesting metadata such as the celebrities featured or the director?
Yes. The v3 API allows you do do this via videos/list. Here's an example API call using a trailer for The Dark Knight Rises:
GET https://www.googleapis.com/youtube/v3/videos?part=topicDetails&id=g8evyE9TuYk&fields=items%2FtopicDetails%2FtopicIds&key={YOUR_API_KEY}
(To get a developer key, follow the instructions in our video tutorial).
That sets:
topic: topicDetails
id: g8evyE9TuYk
fields: items/topicDetails/topicIds
In the response body, you get:
{
"items": [
{
"topicDetails": {
"topicIds": [
"/m/0bpm4yw",
"/m/01d5g",
"/m/0btpm6",
"/m/0184dt",
"/m/02vxn"
]
}
}
]
}
These correspond to Freebase mids, which you can lookup using the Freebase API. For instance, the first response corresponds to the Freebase entity The Dark Knight Rises (movie). Once you look up the entity, you can look up related entities such as the director, actors, or genre.
Play around with the API explorer a bit. When you're ready to translate this into code, watch out video about turning the API reference into code.
I found that I got the metadata details I wanted via this request url:
https://www.googleapis.com/youtube/v3/videos?part=snippet,contentDetails&id={YouTubeVideoID}&key={YourAPIkey}
Here is documentation with description of all the returned data fields.
Here's info on how to get an API key.
I am using Zend's gdata library for the Google Apps provisioning API. Since Zend doesn't yet support fetching org users (no retrieve function provided by the library for this feed), I am making a custom gdata query to the url (as suggested in the documentation developers.google.com/google-apps/provisioning/#retrieving_organization_users_experimental):
apps-apis.google.com/a/feeds/orguser/2.0/'.$customerId.'?get=all
This works well for <= 100 users.
Now, I have created a domain with 125 users across 5 OUs. When I fetch the above URI, I get the 1st 100 users (as documented and expected). However, I could not find the pagination link mentioned here: developers.google.com/google-apps/provisioning/reference#Results_Pagination
Here's the start of my orguser feed:
<?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:apps='http://schemas.google.com/apps/2006'><id>https://apps-apis.google.com/a/feeds/orguser/2.0/C00xxxxxxx</id><updated>2013-01-06T08:17:43.520Z</updated><**link rel='next' type='application/atom+xml' href='https://apps-apis.google.com/a/feeds/orguser/2.0/C00xxxxxxx?get=all&startKey=RASS03jtnz0s2orxmbn.**'/><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='https://apps-apis.google.com/a/feeds/orguser/2.0/C00xxxxx'/>
I tried the https://apps-apis.google.com/a/feeds/orguser/2.0/C00xxxxxxx?get=all&startKey=RASS03jtnz0s2orxmbn. link but it gives me the exact same 100 users that the https://apps-apis.google.com/a/feeds/orguser/2.0/C00xxxxxxx?get=all link gives. This is the only occurrence of the word "next" in my feed and so there is not other URI I can try to fetch the next 25 users.
So I have only been able to get 100 users from this API call. How do I go about fetching the next 25 users? Examples/code would be really appreciated. Or what am I doing wrong?
Please help - this is blocking an urgent delivery.
Thanks!,
Vinay.
Your 2nd request should look like:
https://apps-apis.google.com/a/feeds/orguser/2.0/C00xxxxxx?startKey=RASS03jtnz0s2orxmbn&get=all
startKey should be set to the value of the next parameter and get should continue to be all for each page request.
Also, make sure the URL is decoded, if & is encoded as & in the request, then Google's servers will see all of all&startKey=RASS03jtnz0s2orxmbn as the value of get and it won't see a startKey parameter at all.