Wednesday, May 9, 2012

Finding your Posterous site_id

So, I wrote a plugin that allows users of friendica to cross-post to their posterous blog.
Configuration of the plugin requires the user to know their username, password, api_token, and site_id.

Finding your api_token is easy enough: Just go to posterous.com/api and use the first query to get it.

Finding your site_id is not so clear cut, I'm afraid. I could not find reference to this value anywhere in my user profile on posterous, nor find any mention in the help and FAQ portions of the posterous site.
It's mystifying...how does one find this value?
Of course, if you have more than one posterous blog or site, you will have multiple site_id numbers, but with the friendica plugin only works with one. Presumably, you would use it for a personal posterous blog, or, if you have a friendica acct. set up for some other entity, you would use the posterous site associated with said entity. But, to the matter at hand, how to find this site_id number?
Well, I did figure out how, and it requires a call made over API (not trivial for most users), so I've created two means to find a site_id.:

At this page, you can enter your username, password, and api_token, and the page will return your site ID.
The underlying code of the page is show here: http://tonybaldwin.me/hax/doku.php?id=misc:findpostid
so you can see what the page is doing (to be sure I'm not collecting your login data to post nekkid pix of your mum to your blog or anything, etc.)

That page will only work for those with a single posterous blog (or, at the very least, if you have multiple blogs, it will only return the site_id for the first one), so another method is needed for those who have multiple blogs to sort out their IDs.
For that, at http://tonybaldwin.me/hax/doku.php?id=misc:findpostid I also have included a bash script which will make the same API call, then list all your site nicknames and associated site_id numbers. Full code of the script is shown, with sample output.

I post this here for anyone else as mystified as I was about how to find this value.

keywords: api posterous site_id


./tony

No comments: