Skip to content
This repository has been archived by the owner on May 5, 2021. It is now read-only.

Facebook should make accessing Graph urls easy #2

Open
praeclarum opened this issue Mar 17, 2013 · 0 comments
Open

Facebook should make accessing Graph urls easy #2

praeclarum opened this issue Mar 17, 2013 · 0 comments

Comments

@praeclarum
Copy link
Contributor

Add a GetGraphNode or similar function to FacebookService.

Right now we have to type:

var req = s.CreateRequest (
    "GET",
    new Uri ("https://graph.facebook.com/598072388?fields=friends.fields(first_name,name,gender,updated_time)"),
    account);
var resp = await req.GetResponseAsync ();
var json = JsonObject.Parse (resp.GetResponseText ());

It would be nice to get that down to 1 line:

    public static async Task<JsonObject> GetGraphLinkAsync (this FacebookService facebook, string link, Account account)
    {
        var req = facebook.CreateRequest (
            "GET",
            new Uri (link),
            account);
        using (var resp = await req.GetResponseAsync ()) {
            return (JsonObject)JsonObject.Parse (resp.GetResponseText ());
        }
    }

    public static async Task<JsonObject> GetGraphAsync (this FacebookService facebook, string query, Account account)
    {
        var req = facebook.CreateRequest (
            "GET",
            new Uri ("https://graph.facebook.com/" + query),
            account);
        using (var resp = await req.GetResponseAsync ()) {
            return (JsonObject)JsonObject.Parse (resp.GetResponseText ());
        }
    }
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant