1 Some very rough test scripts for hitting up the OAuth endpoints.
3 These instructions assume you understand the basics of how OAuth
4 works. You may want to read up about it first. Here are some good
5 resources for learning about OAuth:
7 http://hueniverse.com/oauth/
8 http://tools.ietf.org/html/rfc5849
10 To use these scripts (and OAuth in general) first you will need to
11 register and OAuth client application with your StatusNet instance:
13 http://example.status.net/settings/oauthapps
18 Using oauth.ini.sample as a guide, put your StatusNet OAuth endpoints
19 and consumer key and secret in a file called oauth.ini and save it
20 in the same directory as these scripts.
25 Will fetch a request token, token secret and a URL to authorize the
26 token. Once you authorize the request token, you can exchange it
31 $ php fetch_temp_creds.php
33 - oauth_token = 89d481e376edc622f08da5791e6a4446
34 - oauth_token_secret = 6d028bcd1ea125cbed7da2f254219885
36 http://example.status.net/api/oauth/authorize?oauth_token=89d481e376edc622f08da5791e6a4446
38 Now paste the Authorize URL into your browser and authorize your temporary credentials.
43 After you have authorized your request token, you will be presented
44 with a verifier code, or pin, in your browser, which you will need
45 to get an access token. Make sure you copy it into a text buffer
46 or write it down or something. Then call fetch_token_credentials.php
47 to exchange your temporary credentials for real token credentials.
51 $ php fetch_token_creds.php -t 89d481e376edc622f08da5791e6a4446 -s 6d028bcd1ea125cbed7da2f254219885 -v 305162
53 - oauth_token = 9b354df102d8e2b4621122c85d8d045c
54 - oauth_token_secret = 1800a88f1574b47d595214a74e5b1ec5
57 oauth_verify_credentials.php
58 ----------------------------
60 Now you should have real token credentials (an OAuth access token)
61 and you can access protected API resources. This is an example
62 script that calls /api/account/verify_credentials.xml.
66 $ php oauth_verify_creds.php -t 80305cd15c5c69834364ac02d7f9178c -s 673e3b2978b1b92c8edbfe172505fee1
67 <?xml version="1.0" encoding="UTF-8"?>
68 <user xmlns:statusnet="http://status.net/schema/api/1/">
71 <screen_name>zach</screen_name>
73 <description></description>
74 <profile_image_url>http://example.status.net/theme/default/default-avatar-stream.png</profile_image_url>
76 <protected>false</protected>
77 <followers_count>0</followers_count>
78 <profile_background_color></profile_background_color>
79 <profile_text_color></profile_text_color>
80 <profile_link_color></profile_link_color>
81 <profile_sidebar_fill_color></profile_sidebar_fill_color>
82 <profile_sidebar_border_color></profile_sidebar_border_color>
83 <friends_count>0</friends_count>
84 <created_at>Thu Sep 30 23:11:00 +0000 2010</created_at>
85 <favourites_count>0</favourites_count>
86 <utc_offset>0</utc_offset>
87 <time_zone>UTC</time_zone>
88 <profile_background_image_url></profile_background_image_url>
89 <profile_background_tile>false</profile_background_tile>
90 <statuses_count>4</statuses_count>
91 <following>true</following>
92 <statusnet:blocking>false</statusnet:blocking>
93 <notifications>true</notifications>
96 <truncated>false</truncated>
97 <created_at>Wed Oct 06 23:40:14 +0000 2010</created_at>
98 <in_reply_to_status_id></in_reply_to_status_id>
101 <in_reply_to_user_id></in_reply_to_user_id>
102 <in_reply_to_screen_name></in_reply_to_screen_name>
104 <favorited>false</favorited>
105 <statusnet:html>gar</statusnet:html>
107 <statusnet:profile_url>http://example.status.net/statusnet/zach</statusnet:profile_url>
110 oauth_post_notice.php
111 ---------------------
113 This is another test script that lets you post a notice via OAuth.
117 $ php oauth_post_notice.php -t 80305cd15c5c69834364ac02d7f9178c -s 673e3b2978b1b92c8edbfe172505fee1 -u 'Test test test...'
118 <?xml version="1.0" encoding="UTF-8"?>
119 <status xmlns:statusnet="http://status.net/schema/api/1/">
120 <text>Test test test...</text>
121 <truncated>false</truncated>
122 <created_at>Fri Oct 08 02:37:35 +0000 2010</created_at>
123 <in_reply_to_status_id></in_reply_to_status_id>
124 <source><a href="http://banana.com" rel="nofollow">Banana</a></source>
126 <in_reply_to_user_id></in_reply_to_user_id>
127 <in_reply_to_screen_name></in_reply_to_screen_name>
129 <favorited>false</favorited>
133 <screen_name>zach</screen_name>
134 <location></location>
135 <description></description>
136 <profile_image_url>http://example.status.net/statusnet/theme/default/default-avatar-stream.png</profile_image_url>
138 <protected>false</protected>
139 <followers_count>0</followers_count>
140 <profile_background_color></profile_background_color>
141 <profile_text_color></profile_text_color>
142 <profile_link_color></profile_link_color>
143 <profile_sidebar_fill_color></profile_sidebar_fill_color>
144 <profile_sidebar_border_color></profile_sidebar_border_color>
145 <friends_count>0</friends_count>
146 <created_at>Thu Sep 30 23:11:00 +0000 2010</created_at>
147 <favourites_count>0</favourites_count>
148 <utc_offset>0</utc_offset>
149 <time_zone>UTC</time_zone>
150 <profile_background_image_url></profile_background_image_url>
151 <profile_background_tile>false</profile_background_tile>
152 <statuses_count>5</statuses_count>
153 <following>true</following>
154 <statusnet:blocking>false</statusnet:blocking>
155 <notifications>true</notifications>
156 <statusnet:profile_url>http://example.status.net/statusnet/zach</statusnet:profile_url>
158 <statusnet:html>Test test test...</statusnet:html>