简体   繁体   中英

Facebook API: like a photo

In the Facebook API (REST), how do you like a photo? There's a stream.addLike function, but you need the post_id, and I don't see a way to get the post_id of a photo (not the same as the pid or the object_id).

You can now like a photo using Graph API, via a POST to the likes connection on a photo. This did not work previously work but it does now (2011/09/16). Not sure exactly when it got fixed but this one was an oversight for a very long after Graph API was introduced.

First of all you have an Id of Uploaded picture when you are adding this. eg

        var client = new FacebookClient(Access_Token);

        JsonObject jsonResponse = client.Get("me/feed") as JsonObject;
        string feed_ID = string.Empty;
        foreach (var account in (JsonArray)jsonResponse["data"])
        {
            feed_ID = (string)(((JsonObject)account)["id"]);
            goto Next;
        }
    Next: { };

let us say you have got the id of your latest picture uploeded is 12345123_5488224848 now you want to update like this picture. write the following code.

      var client2 = new FacebookClient(Access_Token);
      clientS.Post("12345123_5488224848/likes");

all done. check the status of photo after this.

   var client = new FacebookClient(Access_Token);

    JsonObject jsonResponse = client.Get("me/feed") as JsonObject;
    string feed_ID = string.Empty;
    foreach (var account in (JsonArray)jsonResponse["data"])
    {
        feed_ID = (string)(((JsonObject)account)["id"]);
        goto Next;
    }
Next: { };

I think that the actual photo is classes as the same type of entity os a wallpost, so asloon as you can aquire the stream_id for the photo, it the comments that are attached to the photo you can set stream.addLink found http://developers.facebook.com/docs/reference/rest/stream.addLike Here

By getting the post_id via the photos.get method you should be able to set a comment adn like the object via the stream.addLike.

Hope this helps you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM