static void verify_cb (RestProxyCall *call, const GError *error, GObject *weak_object, gpointer userdata) { MojitoService *service = MOJITO_SERVICE (weak_object); MojitoServiceTwitter *twitter = MOJITO_SERVICE_TWITTER (service); RestXmlNode *node; if (error) { sanity_check_date (call); g_message ("Error: %s", error->message); return; } MOJITO_DEBUG (TWITTER, "Authentication verified"); node = node_from_call (call); if (!node) return; twitter->priv->user_id = g_strdup (rest_xml_node_find (node, "id")->content); twitter->priv->image_url = g_strdup (rest_xml_node_find (node, "profile_image_url")->content); rest_xml_node_unref (node); mojito_service_emit_capabilities_changed (service, get_dynamic_caps (service)); if (twitter->priv->running) get_status_updates (twitter); }
static void _oauth_access_token_cb (RestProxyCall *call, const GError *error, GObject *weak_object, gpointer userdata) { SwService *service = SW_SERVICE (weak_object); SwServiceTwitter *twitter = SW_SERVICE_TWITTER (service); if (error) { sanity_check_date (call); g_message ("Error: %s", error->message); twitter->priv->credentials = CREDS_INVALID; sw_service_emit_capabilities_changed (service, get_dynamic_caps (service)); return; } oauth_proxy_call_parse_token_reponse (OAUTH_PROXY_CALL (call)); SW_DEBUG (TWITTER, "Got OAuth access tokens"); g_object_unref (call); /* Create a TwitPic proxy using OAuth Echo */ twitter->priv->twitpic_proxy = oauth_proxy_new_echo_proxy (OAUTH_PROXY (twitter->priv->proxy), "https://api.twitter.com/1/account/verify_credentials.json", "http://api.twitpic.com/2/", FALSE); /* * Despite the fact we know the credentials are fine, we check them again to * get the user ID and avatar. * * http://apiwiki.twitter.com/Twitter-REST-API-Method:-account verify_credentials */ call = rest_proxy_new_call (twitter->priv->proxy); rest_proxy_call_set_function (call, "1/account/verify_credentials.xml"); rest_proxy_call_async (call, verify_cb, (GObject*)twitter, NULL, NULL); }