Skip to content

Instantly share code, notes, and snippets.

@xdamman
Created March 17, 2012 02:17
Show Gist options
  • Save xdamman/2054395 to your computer and use it in GitHub Desktop.
Save xdamman/2054395 to your computer and use it in GitHub Desktop.
Creating a story with tweets using the Storify API

Get the user token

$ curl -d 'username=apitest&password=test&api_key=4f63e62da2cbc21091d62d60' https://api.storify.com/v1/auth

Response

{"content":{"username":"apitest","_access":0,"bio":null,"location":null,"website":"http://storify.com/apitest","avatar":"http://storify.com/public/img/default.avatar.png","permalink":"http://storify.com/apitest","settings":{"comments":null,"facebook_autoshare":true,"sxsw":false,"notifications":{"newsletter":true,"digest":true,"likes":true,"comments":true,"follower":true,"autoshare":true}},"stats":{"stories":4,"views":0,"embeds":0,"subscriptions":1,"subscribers":0},"date":{"updated":"2012-03-17T01:23:53.504Z","last_seen":"2012-03-17T01:23:53.503Z","featured":null,"created":"2012-03-17T00:17:36.951Z"},"subscribers":[],"subscriptions":[{"username":"storify","_access":1,"name":"Storify","bio":"Making stories from the social Web, finding moments to remember in the real-time stream. Co-founded by @burtherman and @xdamman","location":"Global","website":"http://storify.com","avatar":"https://api.twitter.com/1/users/profile_image/storify?size=bigger","permalink":"http://storify.com/storify","settings":{"notifications":{"newsletter":true,"likes":true,"follower":true,"digest":true,"comments":true},"comments":"facebook"},"stats":{"subscriptions":-19,"subscribers":161717,"stories":79,"followers":596},"date":{"updated":"2012-03-17T01:20:41.162Z","last_seen":"2012-03-15T18:16:27.755Z","featured":null,"created":"2010-09-13T05:16:40.000Z"}}],"identities":[{"service":"gravatar","avatar":"http://www.gravatar.com/avatar/cd51ce292b721b4cb7c5955a25ffc1e0?s=100&d=http%3A%2F%2Fstorify.com%2Fpublic%2Fimg%2Fdefault.avatar.png"}],"_token":"66fb62ec9ea799fa7a8cbd82604b8e78","email":"api@storify.com"},"code":200}

The token is at content._token in the json response. Save it in your app. That's the only thing that you need to authenticate the user in any subsequent request.

Creating the story

$ curl -d 'api_key=4f63e62da2cbc21091d62d60&username=apitest&_token=66fb62ec9ea799fa7a8cbd82604b8e78&story={"title":"Testing Storify API","elements":["https://twitter.com/#!/peteraggie/status/180802901831196672","https://twitter.com/#!/tweetbot/status/180803393563009024","https://twitter.com/#!/peteraggie/status/180805824946520064","https://twitter.com/#!/soma09/status/180806531384745984","https://twitter.com/#!/tweetbot/status/180806815288791040"]}&publish=true'  http://api.storify.com/v1/stories/apitest/create

Response

{"content":{"sid":"4f63f05068e571460e020dd1","title":"Testing Storify API","slug":"testing-storify-api-1","status":"published","permalink":"http://storify.com/apitest/testing-storify-api-1","description":null,"thumbnail":"http://storify.com/public/img/default-thumb.gif","date":{"created":"2012-03-17T02:00:48.112Z","modified":"2012-03-17T02:00:50.239Z","published":"2012-03-17T02:00:50.239Z"},"private":false,"topics":[],"siteposts":[],"meta":{"quoted":[{"username":"peteraggie","name":"Peter Agliata","userid":"165549374","avatar":"http://a0.twimg.com/profile_images/1202914130/peteraggie_normal.jpg","source":"twitter","notified_at":null},{"username":"tweetbot","name":"Tweetbot for iOS","userid":"274626857","avatar":"http://a0.twimg.com/profile_images/1293607765/tweetbot4_normal.png","source":"twitter","notified_at":null},{"username":"soma09","name":"Matthew Vincenty","userid":"15076539","avatar":"http://a0.twimg.com/profile_images/1234229878/image_normal.jpg","source":"twitter","notified_at":null}],"hashtags":[],"created_with":{"href":null,"appname":"tweetbot","name":"TweetBot"}},"stats":{"popularity":0,"views":0,"likes":0,"comments":0,"embeds":[],"elements":{"text":0,"quote":5,"image":0,"video":0,"link":0,"other":0}},"modified":false,"deleted":false,"elements":[]},"code":200}

You can find the permalink of the published story in the content.story.permalink of the json response. http://storify.com/apitest/testing-storify-api-1

@Scottyjames
Copy link

Wow this is amazing, thanks xdamman.
I am a little stuck getting it to work, is there somewhere to learn more to get this done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment