Skip to content

Instantly share code, notes, and snippets.

@xdamman
Created March 23, 2012 19:27
Show Gist options
  • Save xdamman/2174106 to your computer and use it in GitHub Desktop.
Save xdamman/2174106 to your computer and use it in GitHub Desktop.
Creating a story with tweets with the Storify API

Get the user token

$ curl -d 'username=apitest&password=test&api_key=4f63d1315d82b3cfd351917e' 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":11,"views":0,"embeds":0,"subscriptions":1,"subscribers":0},"date":{"updated":"2012-03-23T19:25:34.255Z","last_seen":"2012-03-23T19:25:34.254Z","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":-17,"subscribers":166489,"stories":79,"followers":596},"date":{"updated":"2012-03-23T19:25:17.707Z","last_seen":"2012-03-22T18:38:08.114Z","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":"f1517c15d91a6278372db95bf244454c","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=4f63d1315d82b3cfd351917e&username=apitest&_token=f1517c15d91a6278372db95bf244454c&story={"title":"Testing Storify API","description":"Optional description of the story","elements":["https://twitter.com/#!/YouTernMark/status/182605125817335812","https://twitter.com/#!/elenitamichelle/status/182646622902173696","http://twitter.com/lyndoman/status/181091772716425216","https://twitter.com/#!/ARaytpa/status/180763816857042944"]}&publish=true'  http://api.storify.com/v1/stories/apitest/create

Response

{"content":{"sid":"4f6cce6c77e3e4c43d976674","title":"Testing Storify API","slug":"testing-storify-api-7","status":"published","permalink":"http://storify.com/apitest/testing-storify-api-7","description":"Optional description of the story","thumbnail":"http://storify.com/public/img/default-thumb.gif","date":{"created":"2012-03-23T19:26:36.826Z","modified":"2012-03-23T19:26:37.091Z","published":"2012-03-23T19:26:37.091Z"},"private":false,"topics":[],"siteposts":[],"meta":{"quoted":[{"username":"YouTernMark","name":"Mark Babbitt","userid":"148416446","avatar":"http://a0.twimg.com/profile_images/1203486197/Mark_normal.jpg","source":"twitter","notified_at":null},{"username":"elenitamichelle","name":"Ellen M. Hoffman","userid":"242539166","avatar":"http://a0.twimg.com/profile_images/1225054917/180177_1526220405063_1521240155_31096459_5130345_n_normal.jpg","source":"twitter","notified_at":null},{"username":"lyndoman","name":"Lyndon Antcliff","userid":"1359641","avatar":"http://a0.twimg.com/profile_images/1677215910/fresheggavatar_normal.jpg","source":"twitter","notified_at":null},{"username":"ARaytpa","name":"Ashley Ray","userid":"65116956","avatar":"http://a0.twimg.com/profile_images/1299001836/profilepic_normal.jpg","source":"twitter","notified_at":null}],"hashtags":[],"created_with":{"href":"http://dev.storify.com","appname":"test","name":"Test Application"}},"stats":{"popularity":0,"views":0,"likes":0,"comments":0,"embeds":[],"elements":{"text":0,"quote":4,"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-7

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