Question

Thanks to some of your patience and a small epiphany (sp?), I've now managed to get hold of the user object and groups etc. However, when I try to make calls to the api I notice my shortcomings (no, don't comment - I know you've noticed a while ago :p ). According to Facebook's docs, I should be able to post using something like

    var body = 'Reading Connect JS documentation';
FB.api('/me/feed', 'post', { body: body }, function(response) {
  if (!response || response.error) {
    alert('Error occured');
  } else {
    alert('Post ID: ' + response);
  }
});

However, translated to the SDK, I would assume I would do something like

app.Api("/me/feed", HttpMethod.Post);

but I don't see how I can send the text to write...

Also, while I'm at it - how would I go about using raw fql?

Any takers?

Thanks in advance :)

Was it helpful?

Solution

Well, while an interesting read, the link I was given here didn't really help. Was that the old Sdk?

Anyone know how to get to the elements in this?

        JsonObject friends = app.Api("/me/friends") as JsonObject;
        if (friends != null)
        {
            JsonArray friendsArr = friends["data"] as JsonArray;
            for (int i = 0; i < friendsArr.Count(); i++ )
            {

The data, as I got from the Graph doc is like this:

        // me/friends:
            //"data": [
            //      {
            //         "name": "Jan Voolstra",
            //         "id": "9013644"
            //      },
            //      {
            //         "name": "Christopher O'Rielly",
            //         "id": "9124229"
            //      },

All VS is telling me is that friendsArr[0] is of type Facebook.JsonObject with two elements...

Cheers!

OTHER TIPS

        var fb = new FacebookClient(_accessToken);
        var arguments = new Dictionary<string, object>();
        fb.PostCompleted += (o, args) =>
        {
            if (args.Error == null)
                MessageBox.Show("Your status have been successfully posted to facebook!");
        };
        arguments["message"] = AboutTextBox.Text;
        fb.PostAsync("me/feed", arguments);

How to get items from JsonObject:

List<string>names = new List<string>();
foreach (List<object> listresult in _result.Values)
{
    foreach (JsonObject oneResult in listresult)
    {
            if (oneResult.ContainsKey("name"))
            {
                names.Add(oneResult["name"].ToString());
            }
        }
    }
    break;
}

I think this should work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top