diff options
author | Ross Burton <ross@linux.intel.com> | 2009-05-24 10:49:51 +0100 |
---|---|---|
committer | Ross Burton <ross@linux.intel.com> | 2009-05-24 21:25:01 +0100 |
commit | 4058853009971e158d3cc1fab7d93f9e857fe1a7 (patch) | |
tree | 9c98dc358f334f7a1b557bbbc7825f7b59c1e7ce | |
parent | e305b3f8039c566ad251365a89828cb8735f21a0 (diff) |
Fetch status updates in the facebook test
-rw-r--r-- | examples/test-facebook.c | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/examples/test-facebook.c b/examples/test-facebook.c index d4bcb8f..dac21e1 100644 --- a/examples/test-facebook.c +++ b/examples/test-facebook.c @@ -34,7 +34,7 @@ main (int argc, char **argv) RestProxyCall *call; RestXmlNode *root, *node; const char *secret, *session_key; - char *token, *url; + char *token, *url, *name; g_thread_init (NULL); g_type_init (); @@ -84,18 +84,40 @@ main (int argc, char **argv) facebook_proxy_set_app_secret (FACEBOOK_PROXY (proxy), secret); } - /* Make an authenticated call */ + /* Make some authenticated calls */ + + /* Get the user name */ call = rest_proxy_new_call (proxy); rest_proxy_call_set_function (call, "users.getInfo"); rest_proxy_call_add_param (call, "uids", "1340627425"); - rest_proxy_call_add_param (call, "fields", "uid,name"); + rest_proxy_call_add_param (call, "fields", "name"); if (!rest_proxy_call_run (call, NULL, NULL)) g_error ("Cannot get user info"); root = get_xml (call); node = rest_xml_node_find (root, "name"); - g_print ("Logged in as %s\n", node->content); + name = g_strdup (node->content); + g_print ("Logged in as %s\n", name); + rest_xml_node_unref (root); + + /* Get the user status messages */ + call = rest_proxy_new_call (proxy); + rest_proxy_call_set_function (call, "status.get"); + rest_proxy_call_add_param (call, "limit", "5"); + + if (!rest_proxy_call_run (call, NULL, NULL)) + g_error ("Cannot get statuses"); + + root = get_xml (call); + { + RestXmlNode *node, *msg; + for (node = rest_xml_node_find (root, "status"); node; node = node->next) { + msg = rest_xml_node_find (node, "message"); + g_print ("%s %s\n", name, msg->content); + } + } + rest_xml_node_unref (root); return 0; } |