summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/Makefile.am9
-rw-r--r--examples/test-json.c45
2 files changed, 51 insertions, 3 deletions
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 3ac2af5..7c4486f 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -1,5 +1,8 @@
-noinst_PROGRAMS = test-raw
+noinst_PROGRAMS = test-raw test-json
+
+AM_CFLAGS = $(GLIB_CFLAGS) $(SOUP_CFLAGS) $(JSON_CFLAGS) -I..
+AM_LDFLAGS = $(GLIB_LIBS) $(SOUP_LIBS) $(JSON_LIBS) ../rest/librest.la
test_raw_SOURCES = test-raw.c
-test_raw_LDADD = $(GLIB_LIBS) $(SOUP_LIBS) ../rest/librest.la
-test_raw_CFLAGS = $(GLIB_CFLAGS) $(SOUP_CFLAGS) -I..
+test_json_SOURCES = test-json.c
+
diff --git a/examples/test-json.c b/examples/test-json.c
new file mode 100644
index 0000000..efd9cd7
--- /dev/null
+++ b/examples/test-json.c
@@ -0,0 +1,45 @@
+#include <rest/rest-proxy.h>
+
+static void
+proxy_call_json_async_cb (RestProxy *proxy,
+ guint status_code,
+ const gchar *response_message,
+ GHashTable *headers,
+ JsonNode *root,
+ GObject *weak_object,
+ gpointer userdata)
+{
+ g_main_loop_quit ((GMainLoop *)userdata);
+}
+
+gint
+main (gint argc, gchar **argv)
+{
+ RestProxy *proxy;
+ GMainLoop *loop;
+ gchar *payload;
+ gssize len;
+
+ g_type_init ();
+ g_thread_init (NULL);
+
+ loop = g_main_loop_new (NULL, FALSE);
+
+ proxy = rest_proxy_new ("http://www.flickr.com/services/rest/", FALSE);
+ rest_proxy_call_json_async (proxy,
+ NULL,
+ "GET",
+ proxy_call_json_async_cb,
+ NULL,
+ loop,
+ NULL,
+ "method",
+ "flickr.test.echo",
+ "api_key",
+ "314691be2e63a4d58994b2be01faacfb",
+ "format",
+ "json",
+ NULL);
+
+ g_main_loop_run (loop);
+}