Skip to content

Instantly share code, notes, and snippets.

@abraham
Created August 20, 2010 08:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save abraham/539914 to your computer and use it in GitHub Desktop.
Save abraham/539914 to your computer and use it in GitHub Desktop.
OAuth 2 with the Twitter API
localStorage.getItem("twttr_anywhere");
// "9436992-QKOV6cNsfeRe9Kagyy4AmQF7WX2efs3rRDgyEy7Bvsfeaf"
<!-- User hits the oauth_callback_url with an oauth_access_token -->
http://abrah.am/#oauth_access_token=9436992-QKOV6cNsfeRe9Kagyy4AmQF7WX2efs3rRDgyEy7Bvsfeaf&oauth_bridge_code=JKOPZJbnQ7fPAQxFoYJasfsefSFefss7WDP7z5l
<!-- Use your oauth_callback_url and your oauth_client_identifier aka the @Anywhere API key -->
https://oauth.twitter.com/2/authorize?oauth_callback_url=http://abrah.am/&oauth_mode=flow_web_client&oauth_client_identifier=9QR94sYuXI3j6XkYrr1Ybw
// $ curl -d 'screen_name=abraham&text=test+message&oauth_access_token=9436992-QKOV6cNsfeRe9Kagyy4AmQF7WX2efs3rRDgyEy7Bvsfeaf' https://api.twitter.com/direct_messages/new.json
{
"created_at": "Fri Aug 20 09:15:59 +0000 2010",
"sender": {
"description": "Hacker Advocate looking for interesting people and projects. Drupal and Twitter API developer. Currently learning Python, App Engine, Ruby on Rails, and jQuery.",
"listed_count": 295,
"lang": "en",
"profile_use_background_image": false,
"time_zone": "Pacific Time (US & Canada)",
"created_at": "Sun Oct 14 12:50:47 +0000 2007",
"friends_count": 412,
"location": "Seattle, WA",
"statuses_count": 17149,
"notifications": false,
"profile_background_color": "ffffff",
"show_all_inline_media": false,
"profile_background_image_url": "http://a3.twimg.com/profile_background_images/63275387/White_Crystal.jpg",
"favourites_count": 483,
"contributors_enabled": false,
"following": false,
"profile_text_color": "454545",
"geo_enabled": true,
"profile_background_tile": false,
"profile_link_color": "33ccff",
"verified": false,
"protected": false,
"profile_image_url": "http://a3.twimg.com/profile_images/54160223/chart-black-small_normal.png",
"follow_request_sent": false,
"profile_sidebar_fill_color": "ffffff",
"name": "Abraham Williams",
"screen_name": "abraham",
"id": 9436992,
"utc_offset": -28800,
"profile_sidebar_border_color": "12BEF2",
"followers_count": 2206,
"url": "http://abrah.am/"
},
"sender_screen_name": "abraham",
"recipient": {
"description": "Hacker Advocate looking for interesting people and projects. Drupal and Twitter API developer. Currently learning Python, App Engine, Ruby on Rails, and jQuery.",
"listed_count": 295,
"lang": "en",
"profile_use_background_image": false,
"time_zone": "Pacific Time (US & Canada)",
"created_at": "Sun Oct 14 12:50:47 +0000 2007",
"friends_count": 412,
"location": "Seattle, WA",
"statuses_count": 17149,
"notifications": false,
"profile_background_color": "ffffff",
"show_all_inline_media": false,
"profile_background_image_url": "http://a3.twimg.com/profile_background_images/63275387/White_Crystal.jpg",
"favourites_count": 483,
"contributors_enabled": false,
"following": false,
"profile_text_color": "454545",
"geo_enabled": true,
"profile_background_tile": false,
"profile_link_color": "33ccff",
"verified": false,
"protected": false,
"profile_image_url": "http://a3.twimg.com/profile_images/54160223/chart-black-small_normal.png",
"follow_request_sent": false,
"profile_sidebar_fill_color": "ffffff",
"name": "Abraham Williams",
"screen_name": "abraham",
"id": 9436992,
"utc_offset": -28800,
"profile_sidebar_border_color": "12BEF2",
"followers_count": 2206,
"url": "http://abrah.am/"
},
"recipient_screen_name": "abraham",
"sender_id": 9436992,
"recipient_id": 9436992,
"id": 1506478094,
"text": "test message"
}
// $ curl https://api.twitter.com/1/account/verify_credentials.json?oauth_access_token=9436992-QKOV6cNsfeRe9Kagyy4AmQF7WX2efs3rRDgyEy7Bvsfeaf
{
"statuses_count": 17149,
"description": "Hacker Advocate looking for interesting people and projects. Drupal and Twitter API developer. Currently learning Python, App Engine, Ruby on Rails, and jQuery.",
"show_all_inline_media": false,
"lang": "en",
"profile_use_background_image": false,
"time_zone": "Pacific Time (US & Canada)",
"favourites_count": 483,
"created_at": "Sun Oct 14 12:50:47 +0000 2007",
"location": "Seattle, WA",
"status": {
"in_reply_to_user_id": null,
"in_reply_to_status_id": null,
"geo": null,
"created_at": "Fri Aug 20 08:39:14 +0000 2010",
"coordinates": null,
"retweeted": false,
"favorited": false,
"truncated": false,
"contributors": null,
"source": "web",
"place": {
"bounding_box": {
"type": "Polygon",
"coordinates": [
[
[-122.324689, 47.611409],
[-122.324689, 47.611409],
[-122.324689, 47.611409],
[-122.324689, 47.611409]
]
]
},
"attributes": {
"street_address": "1215 Seneca St"
},
"full_name": "Tuscany Apartments, Seattle",
"place_type": "poi",
"name": "Tuscany Apartments",
"country": "The United States of America",
"country_code": "US",
"id": "adb50bed081f9502",
"url": "http://api.twitter.com/1/geo/id/adb50bed081f9502.json"
},
"in_reply_to_screen_name": null,
"retweet_count": null,
"id": 21648851863,
"text": "One quarter of a century..."
},
"contributors_enabled": false,
"notifications": null,
"profile_background_color": "ffffff",
"geo_enabled": true,
"profile_background_image_url": "http://a3.twimg.com/profile_background_images/63275387/White_Crystal.jpg",
"following": null,
"profile_text_color": "454545",
"verified": false,
"profile_background_tile": false,
"follow_request_sent": null,
"profile_link_color": "33ccff",
"protected": false,
"profile_image_url": "http://a3.twimg.com/profile_images/54160223/chart-black-small_normal.png",
"profile_sidebar_fill_color": "ffffff",
"followers_count": 2206,
"name": "Abraham Williams",
"screen_name": "abraham",
"id": 9436992,
"listed_count": 295,
"utc_offset": -28800,
"friends_count": 412,
"profile_sidebar_border_color": "12BEF2",
"url": "http://abrah.am/"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment