Mike Kippen
Mike Kippen

Reputation: 11

Facebook C# SDK batch request feed with object_id for photo data

I am using the C# Facebook SDK to query Facebook for the /home feed and the feed contains photos. The "picture" link in the feed is low resolution, so I have to look up the "object_id" for the photo from the feed to get the high resolution versions.

This is what I want to accomplish

  1. Get /home feed
  2. From all "object_id" in /home response, get "object_id"

        Common._fb.BatchTaskAsync(new[]{
            new FacebookBatchParameter(HttpMethod.Get, "/me", new Dictionary<string, object> { { "limit", 25 }, {"access_token", Common._fb.AccessToken} }),
            new FacebookBatchParameter("/me/home", new { limit = 25 }) { Data = new { name = "home-feed", omit_response_on_success = false } },
            new FacebookBatchParameter(HttpMethod.Get, "/{result=home-feed:$.data.*.object_id}", new { limit = 25 }),                
            new FacebookBatchParameter("/me/error")});
    

The problem I have is that the object_id calls fail with the following exception:

{"error":{"message":"(#803) Some of the aliases you requested do not exist: 432468803491390,10151350857109036,388654974561669,197117360426100,443878372332478,445366662199631,457265447662406,475836539118390,474145425981640,363838440380681","type":"OAuthException","code":803}} object {Facebook.JsonObject}

This is what the data from the first call looks like:

"type": "photo", "status_type": "shared_story", "object_id": "379861798777414", 

In the graph API, the object_id can be queried directly like this: /379861798777414

id": 
"379861798777414", 
  "from": 
{
    "category": 
"Automobiles and parts", 
    "name": 
"Legendary Speed Inc.", 
"id": 
"142234555873474"
  }, 
  "name": 
"FOR SALE:\nClick the link for Price and Info\nhttp://www.legendaryfind.com/cars/pin/38000/", 
  "picture": 
"https://photos-b.xx.fbcdn.net/hphotos-ash4/603137_379861798777414_485849814_s.jpg", 
  "source": 
"https://sphotos-b.xx.fbcdn.net/hphotos-ash4/603137_379861798777414_485849814_n.jpg", 
  "height": 
265, 
  "width": 
400, 
  "images": 
[ 
{
 "height": 1356, 
 "width": 2048, 
"source": "https://sphotos-b.xx.fbcdn.net/hphotos-ash4/s2048x2048/603137_379861798777414_485849814_n.jpg"
} 

I don't know why, but I am unable to call for the object_id from the batchparameter like this. Kinda stuck here.

Upvotes: 1

Views: 853

Answers (1)

Mike Kippen
Mike Kippen

Reputation: 11

After discovering FQL, the graph calls are a thing of the past. New code for FQL is much faster and more efficient at doing this:

stream = "SELECT post_id, actor_id, created_time, message, attachment FROM stream WHERE filter_key IN ( SELECT filter_key FROM stream_filter WHERE uid=me() AND type='newsfeed')", //WHERE source_id = me()
users = "SELECT uid, name from user WHERE uid IN (SELECT actor_id FROM #stream)",
photos = "SELECT images, caption, like_info FROM photo WHERE pid IN (SELECT attachment.fb_object_id FROM #stream)"

Upvotes: 0

Related Questions