OAuthProxy
Object Hierarchy:
Rest.OAuthProxy
Rest.OAuthProxy
Rest.OAuthProxy
Rest.Proxy
Rest.Proxy
Rest.Proxy->Rest.OAuthProxy
GLib.Object
GLib.Object
GLib.Object->Rest.Proxy
Description:
[
CCode ( cname =
"OAuthProxy" , lower_case_cprefix =
"oauth_proxy_" , type_id =
"oauth_proxy_get_type ()" ) ]
public class OAuthProxy :
Proxy
OAuthProxy has no publicly available members.
Example: Twitter, continuous:
public class Twitter : Object { public void run () { // Create the proxy: Rest.OAuthProxy proxy = new Rest.OAuthProxy ( "UfXFxDbUjk41scg0kmkFwA" , // the consumer key "pYQlfI2ZQ1zVK0f01dnfhFTWzizBGDnhNJIw6xwto" , // the consumer secret "https://api.twitter.com/" , // the endpoint url false ); // First stage authentication, this gets a request token: try { proxy.request_token ("oauth/request_token" , "oob" ); } catch (Error e) { error ("Cannot get request token: %s " , e.message); } // From the token construct a URL for the user to visit: print ("Go to http://twitter.com/oauth/authorize?oauth_token= %s then enter the PIN \n " , proxy.get_token ()); string pin = stdin.read_line (); pin._chomp (); // Second stage authentication, this gets an access token: try { proxy.access_token ("oauth/access_token" , pin); } catch (Error e) { error ("Cannot get access token: %s " , e.message); } // // We're now authenticated! // // Post the status message: Rest.ProxyCall call = proxy.new_call (); proxy.url_format = "http://stream.twitter.com/" ; call.set_function ("1/statuses/filter.json" ); call.set_method ("GET" ); call.add_param ("track" , "Cameron" ); call.add_param ("delimited" , "length" ); try { call.continuous ((call, str, len, err, obj) => { print (str); print (" \n " ); }, this ); } catch (Error e) { error ("continuous: %s " , e.message); } } public static int main (string [] args) { MainLoop loop = new MainLoop (); Twitter twitter = new Twitter (); twitter.run (); loop.run (); twitter = null ; return 0 ; } }
valac --pkg rest-0.7 continuous-twitter.vala
Content:
Properties:
Creation methods:
public OAuthProxy (string consumer_key, string consumer_secret, string url_format, bool binding_required)
Create a new OAuthProxy for the specified
endpoint url_format
, using the specified API key and secret.
public OAuthProxy.with_token (string consumer_key, string consumer_secret, string token, string token_secret, string url_format, bool binding_required)
Create a new OAuthProxy for the specified
endpoint url_format
, using the specified API key and secret.
Methods:
public bool access_token (string function, string verifier) throws Error
Perform the Access Token phase of OAuth, invoking function
(defaulting to "access_token" if function
is NULL).
public bool access_token_async (string function, string verifier, OAuthProxyAuthCallback callback, Object weak_object) throws Error
Perform the Access Token phase of OAuth, invoking function
(defaulting to "access_token" if function
is NULL).
public bool auth_step (string function) throws Error
Perform an OAuth authorisation step.
public bool auth_step_async (string function, OAuthProxyAuthCallback callback, Object weak_object) throws Error
Perform an OAuth authorisation step.
public unowned string get_signature_host ()
Get the signature hostname used when creating a signature base string.
public unowned string get_token ()
Get the current request or access token.
public unowned string get_token_secret ()
Get the current request or access token secret.
public bool is_oauth10a ()
Determines if the server supports OAuth 1.0a with this proxy.
public Proxy new_echo_proxy (string service_url, string url_format, bool binding_required)
public bool request_token (string function, string callback_uri) throws Error
Perform the Request Token phase of OAuth, invoking function
(defaulting to "request_token" if function
is NULL).
public bool request_token_async (string function, string callback_uri, OAuthProxyAuthCallback callback, Object weak_object) throws Error
Perform the Request Token phase of OAuth, invoking function
(defaulting to "request_token" if function
is NULL).
public void set_signature_host (string signature_host)
Set the signature hostname used when creating a signature base string.
public void set_token (string token)
Set the access token.
public void set_token_secret (string token_secret)
Set the access token secret.
Inherited Members:
All known members inherited from class Rest.Proxy
All known members inherited from class GLib.Object
@get
@new
@ref
@set
add_toggle_ref
add_weak_pointer
bind_property
connect
constructed
disconnect
dispose
dup_data
dup_qdata
force_floating
freeze_notify
get_class
get_data
get_property
get_qdata
get_type
getv
interface_find_property
interface_install_property
interface_list_properties
is_floating
new_valist
new_with_properties
newv
notify
notify_property
ref_count
ref_sink
remove_toggle_ref
remove_weak_pointer
replace_data
replace_qdata
set_data
set_data_full
set_property
set_qdata
set_qdata_full
set_valist
setv
steal_data
steal_qdata
thaw_notify
unref
watch_closure
weak_ref
weak_unref