开发者

What is the url to a Facebook open graph post?

Given a post id returned by a graph search, for example: 186173001411937

is there a url to link to the post in facebook? The following url does not work:开发者_开发技巧 http://www.facebook.com/post.php?id=186173001411937


I found out, for a graph id 1099696306_140549259338782 the links is build like this: http://www.facebook.com/1099696306/posts/140549259338782


Honestly, the simplest way I've found to do this is just:

"http://www.facebook.com/" + postId

Where postId is just the straight id of the post (186173001411937), not the userid_postid variant.


with the graph api v2.5 you can use the permalink_url field of the the posts object.

i.e.:

www.facebook.com/v2.5/{pagename}/?fields=posts{permalink_url,message,story,created_time,id}

will return

"posts": {
   "data": [
   {
    "permalink_url": "https://www.facebook.com/etsmtl/posts/10153868925494376",
    "message": "Le Club Cedille organise le prochain Linux-Meetup ce soir à l'ÉTS. Au programme : conférence de James Shubin, ingénieur logiciel sénior chez Red Hat.",
    "created_time": "2016-03-01T15:23:11+0000",
    "id": "8632204375_10153868925494376"
   }, ... }


With regards to a public facing page post take the Id returned from the Facebook Graph API e.g. 12345678_12345678 and append it to facebook.com e.g. https://www.facebook.com/12345678_12345678. The post is also highlighted as you access the page.


 public <T>getPagePosts(string pageId, string access_token, int limit)
        {
            var client = new RestClient("https://graph.facebook.com");
            var request = new RestRequest(Method.GET);
            var fields = "posts{permalink_url,picture,message,story,created_time,id}";
            request.Resource = "{version}/{object_id}/";
            request.RequestFormat = DataFormat.Json;
            request.JsonSerializer.ContentType = "application/json;";
            request.AddParameter("access_token", access_token);
            request.AddParameter("version", "v2.10", ParameterType.UrlSegment);
            request.AddParameter("object_id", pageId, ParameterType.UrlSegment);
            request.AddParameter("limit", limit);
            request.AddParameter("fields", fields);
            var response = client.Execute(request);
            var result = JsonConvert.DeserializeObject<T>(response.Content);
            return result;
        }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜