TheDrunkenEpic - Drunken Ramblings of a Code Monkey
Filed under

api

 

Snaggr Goes Tender!

I've been searching for a decent and, most importantly, simple wiki solution now for the past few weeks. I needed something easy to use and manage for Snaggr's documentation. All of the potential software I found were either too bloated or too shithouse to use.

Maintaining documentation using a simple medium with a decent built-in search and suggest system is pretty important. Especially when it comes to writing pages upon pages of instructions and standards for something that's constantly changing and growing. I shouldn't have to think about how to use the software, I just want to fucking post shit and easily organize it.

Even though I'm on a pretty tight, self-imposed, deadline for the API, I actually took the some time off yesterday and began writing my own wiki solution on top of the Kohana framewok. Three hours into it I decided to take a small break and search around on the net for other APIs I could potentially integrate into Snaggr. I happened upon a nice little service named Ember.

According to Ember it's:

"... the best way to share your design inspiration with the world - from webpages to screenshots, design to illustration, Ember is built for creatives looking to build an online design scrapbook."

Ok.

Well, the screenshot and illustration part caught my attention and I quickly discovered they provide a simple API. Unfortunately, according to it's online documentation, it doesn't support text-based search, but that's besides the point of this post. I noticed that Ember's support documentation is externally hosted by another service; Tender Support.

Apparently, it's by the same guys who created Lighthouse, which is an issue tracking system I used to use. I really liked working with Lighthouse and figured if it's by the same guys, Tender Support must be alright as well. I signed up for the 30 trial and began working.

Tender pretty much has everything I need to get the documentation up and running quickly. It's also very simple manage all your data. It even has built-in discussion forums for support and feedback as well as issue tracking. This is perfect for API support when things go wrong. So, what the hell, I liked it so much signed up for the basic plan.

A very large chunk of the API documentation has already been completed and I'm hoping to get most of it done by this weekend. Hopefully, if all goes well, I can get a few people together to begin testing the API out.

Stoked!

As always, be sure to follow us on Twitter and check the site out!

Loading mentions Retweet
Filed under  //   api   Snaggr   Support  

Comments [0]

Import Content Into Posterous Using PHP + cURL + RSS ...

Before I moved to Posterous from Symphony, I had to take a serious thought as to how I was going to transfer my old content into my new account. I didn't want to manually transfer my articles over and Posterous doesn't offer any kind of import feature for my system. Besides, either way, I was going to lose all of my visitor's comments. I actually considered trashing all my old content and start fresh just so I wouldn't have to deal with the issue.

So, obviously, I decided to go ahead and find an easy way to move my stuff to a new home. By using a combination of PHP, cURL and RSS I was able to easily accomplish this within minutes. Since I'm such a nice guy, I'll go ahead and show you how I did it.

After digging around this service, I found that Posterous provides a very simple REST-based API which, among other things, allows you to post new content to one of your sites.

I then realized I could use my current site's RSS feed as the source of my content. I went ahead and changed the settings to this feed to display every article I ever wrote on the site.

Next, I cracked my knuckles and got to work writing the following script:

<?php 

set_time_limit(0);

define('IMPORT_RSS', 'http://www.mysite.com/'); // A direct link to the RSS feed you wish to import posts from ...
define('IMPORT_SITE_ID', 69); // The id of one of your Posterous sites ...
define('IMPORT_SITE_EMAIL', 'my@email.com'); // The email address assigned to your Posterous account ...
define('IMPORT_SITE_PASSWORD', 'password'); // The password assigned to your Posterous account ...

$RSS = new SimpleXMLElement(file_get_contents(IMPORT_RSS));

foreach($RSS->channel->item as $Entry)
{
$values = array
(
'site_id' => IMPORT_SITE_ID,
'title' => $Entry->title,
'body' => $Entry->description,
'date' => $Entry->pubDate,
);

$curl = curl_init('posterous.com/api/newpost');

curl_setopt($curl, CURLOPT_USERPWD, IMPORT_SITE_EMAIL . ':' . IMPORT_SITE_PASSWORD);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $values);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

curl_exec($curl);

curl_close($curl);
}

Before you run this script, be sure you have PHP5 compiled with cURL support. Simply change the above constants to their appropriate values, make sure your RSS feed is valid, upload the script and execute it in your browser. If your values are correct, you will start noticing your articles appearing in the proper order in your Posterous account.

Sweet!

Clearly, there are fancier ways to do this, but there's no need to create overly elaborate code I'm only going to be running once.

NOTE:

One thing you should realize when using the API, the REST end points should NOT include any part of the 'http://www.' prefix. Doing so will cause authentication errors even if you're using the correct credentials. This stalled me for a good hour or so and with the limited documentation, I was left to resolve the issue with no help. Hopefully, if you're having the same problem, this will help you out. If not, contact the Posterous support peeps.

Till next time!

Loading mentions Retweet
Filed under  //   api   curl   php   posterous   rss   xml  

Comments [1]