Skip to content

Instantly share code, notes, and snippets.

@xdamman

xdamman/gist:2129345

Created Mar 20, 2012
Embed
What would you like to do?
Create a story with tweets using the Storify API

Get the user token

$ curl -d 'username=apitest&password=test&api_key=4f67d405d06efbdac993a3cf' 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":"d5850e806384c66649a4e3cbb173c611","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=4f67d405d06efbdac993a3cf&username=apitest&_token=d5850e806384c66649a4e3cbb173c611&story={"title":"Testing Storify API","elements":["https://twitter.com/#!/Stevewillhite/status/181679918743175168","https://twitter.com/#!/thevainphotos/status/180724315220742144","https://twitter.com/#!/xab3lle/status/180059326885543938"]}&publish=true'  http://api.storify.com/v1/stories/apitest/create

Response

{"content":{"sid":"4f67d64953730640042232fd","title":"Testing Storify API","slug":"testing-storify-api-2","status":"published","permalink":"http://storify.com/apitest/testing-storify-api-2","description":null,"thumbnail":"http://storify.com/public/img/default-thumb.gif","date":{"created":"2012-03-20T00:58:49.506Z","modified":"2012-03-20T00:58:50.850Z","published":"2012-03-20T00:58:50.850Z"},"private":false,"topics":[],"siteposts":[],"meta":{"quoted":[{"username":"Stevewillhite","name":"Steve Willhite","userid":"91191989","avatar":"http://a0.twimg.com/profile_images/1854584074/anniversary9_normal.jpg","source":"twitter","notified_at":null},{"username":"thevainphotos","name":"Carl Sukonik","userid":"79525519","avatar":"http://a0.twimg.com/profile_images/1592492865/111016_portrait_shots_009_normal.jpg","source":"twitter","notified_at":null},{"username":"xab3lle","name":"christabelletani","userid":"56098387","avatar":"http://a0.twimg.com/profile_images/1608720769/image_normal.jpg","source":"twitter","notified_at":null},{"username":"TweetDeck","name":null,"avatar":"http://api.twitter.com/1/users/profile_image/TweetDeck","source":"twitter","notified_at":null}],"hashtags":[],"created_with":{"href":"http://tweetdeck.com","appname":"tweetdeck","name":"TweetDeck"}},"stats":{"popularity":0,"views":0,"likes":0,"comments":0,"embeds":[],"elements":{"text":0,"quote":3,"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-2

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