README 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. Some very rough test scripts for hitting up the OAuth endpoints.
  2. These instructions assume you understand the basics of how OAuth
  3. works. You may want to read up about it first. Here are some good
  4. resources for learning about OAuth:
  5. http://hueniverse.com/oauth/
  6. http://tools.ietf.org/html/rfc5849
  7. To use these scripts (and OAuth in general) first you will need to
  8. register and OAuth client application with your StatusNet instance:
  9. http://example.status.net/settings/oauthapps
  10. oauth.ini
  11. ---------
  12. Using oauth.ini.sample as a guide, put your StatusNet OAuth endpoints
  13. and consumer key and secret in a file called oauth.ini and save it
  14. in the same directory as these scripts.
  15. fetch_temp_creds.php
  16. --------------------
  17. Will fetch a request token, token secret and a URL to authorize the
  18. token. Once you authorize the request token, you can exchange it
  19. for an access token.
  20. example usage:
  21. $ php fetch_temp_creds.php
  22. Request Token
  23. - oauth_token = 89d481e376edc622f08da5791e6a4446
  24. - oauth_token_secret = 6d028bcd1ea125cbed7da2f254219885
  25. Authorize URL
  26. http://example.status.net/api/oauth/authorize?oauth_token=89d481e376edc622f08da5791e6a4446
  27. Now paste the Authorize URL into your browser and authorize your temporary credentials.
  28. fetch_token_creds.php
  29. ---------------------
  30. After you have authorized your request token, you will be presented
  31. with a verifier code, or pin, in your browser, which you will need
  32. to get an access token. Make sure you copy it into a text buffer
  33. or write it down or something. Then call fetch_token_credentials.php
  34. to exchange your temporary credentials for real token credentials.
  35. example usage:
  36. $ php fetch_token_creds.php -t 89d481e376edc622f08da5791e6a4446 -s 6d028bcd1ea125cbed7da2f254219885 -v 305162
  37. Access Token
  38. - oauth_token = 9b354df102d8e2b4621122c85d8d045c
  39. - oauth_token_secret = 1800a88f1574b47d595214a74e5b1ec5
  40. oauth_verify_credentials.php
  41. ----------------------------
  42. Now you should have real token credentials (an OAuth access token)
  43. and you can access protected API resources. This is an example
  44. script that calls /api/account/verify_credentials.xml.
  45. example usage:
  46. $ php oauth_verify_creds.php -t 80305cd15c5c69834364ac02d7f9178c -s 673e3b2978b1b92c8edbfe172505fee1
  47. <?xml version="1.0" encoding="UTF-8"?>
  48. <user xmlns:statusnet="http://status.net/schema/api/1/">
  49. <id>23</id>
  50. <name>zach</name>
  51. <screen_name>zach</screen_name>
  52. <location></location>
  53. <description></description>
  54. <profile_image_url>http://example.status.net/theme/default/default-avatar-stream.png</profile_image_url>
  55. <url></url>
  56. <protected>false</protected>
  57. <followers_count>0</followers_count>
  58. <profile_background_color></profile_background_color>
  59. <profile_text_color></profile_text_color>
  60. <profile_link_color></profile_link_color>
  61. <profile_sidebar_fill_color></profile_sidebar_fill_color>
  62. <profile_sidebar_border_color></profile_sidebar_border_color>
  63. <friends_count>0</friends_count>
  64. <created_at>Thu Sep 30 23:11:00 +0000 2010</created_at>
  65. <favourites_count>0</favourites_count>
  66. <utc_offset>0</utc_offset>
  67. <time_zone>UTC</time_zone>
  68. <profile_background_image_url></profile_background_image_url>
  69. <profile_background_tile>false</profile_background_tile>
  70. <statuses_count>4</statuses_count>
  71. <following>true</following>
  72. <statusnet:blocking>false</statusnet:blocking>
  73. <notifications>true</notifications>
  74. <status>
  75. <text>gar</text>
  76. <truncated>false</truncated>
  77. <created_at>Wed Oct 06 23:40:14 +0000 2010</created_at>
  78. <in_reply_to_status_id></in_reply_to_status_id>
  79. <source>web</source>
  80. <id>7</id>
  81. <in_reply_to_user_id></in_reply_to_user_id>
  82. <in_reply_to_screen_name></in_reply_to_screen_name>
  83. <geo></geo>
  84. <favorited>false</favorited>
  85. <statusnet:html>gar</statusnet:html>
  86. </status>
  87. <statusnet:profile_url>http://example.status.net/statusnet/zach</statusnet:profile_url>
  88. </user>
  89. oauth_post_notice.php
  90. ---------------------
  91. This is another test script that lets you post a notice via OAuth.
  92. example usage:
  93. $ php oauth_post_notice.php -t 80305cd15c5c69834364ac02d7f9178c -s 673e3b2978b1b92c8edbfe172505fee1 -u 'Test test test...'
  94. <?xml version="1.0" encoding="UTF-8"?>
  95. <status xmlns:statusnet="http://status.net/schema/api/1/">
  96. <text>Test test test...</text>
  97. <truncated>false</truncated>
  98. <created_at>Fri Oct 08 02:37:35 +0000 2010</created_at>
  99. <in_reply_to_status_id></in_reply_to_status_id>
  100. <source>&lt;a href=&quot;http://banana.com&quot; rel=&quot;nofollow&quot;&gt;Banana&lt;/a&gt;</source>
  101. <id>8</id>
  102. <in_reply_to_user_id></in_reply_to_user_id>
  103. <in_reply_to_screen_name></in_reply_to_screen_name>
  104. <geo></geo>
  105. <favorited>false</favorited>
  106. <user>
  107. <id>23</id>
  108. <name>zach</name>
  109. <screen_name>zach</screen_name>
  110. <location></location>
  111. <description></description>
  112. <profile_image_url>http://example.status.net/statusnet/theme/default/default-avatar-stream.png</profile_image_url>
  113. <url></url>
  114. <protected>false</protected>
  115. <followers_count>0</followers_count>
  116. <profile_background_color></profile_background_color>
  117. <profile_text_color></profile_text_color>
  118. <profile_link_color></profile_link_color>
  119. <profile_sidebar_fill_color></profile_sidebar_fill_color>
  120. <profile_sidebar_border_color></profile_sidebar_border_color>
  121. <friends_count>0</friends_count>
  122. <created_at>Thu Sep 30 23:11:00 +0000 2010</created_at>
  123. <favourites_count>0</favourites_count>
  124. <utc_offset>0</utc_offset>
  125. <time_zone>UTC</time_zone>
  126. <profile_background_image_url></profile_background_image_url>
  127. <profile_background_tile>false</profile_background_tile>
  128. <statuses_count>5</statuses_count>
  129. <following>true</following>
  130. <statusnet:blocking>false</statusnet:blocking>
  131. <notifications>true</notifications>
  132. <statusnet:profile_url>http://example.status.net/statusnet/zach</statusnet:profile_url>
  133. </user>
  134. <statusnet:html>Test test test...</statusnet:html>
  135. </status>