News Archive
PhpRiot Newsletter
Your Email Address:

More information

Fetching Your Talks from the Joind.In API

Note: This article was originally published at Planet PHP on 18 April 8120.
Planet PHP

I'm a regular speaker at a variety of (okay, mostly technical, so not really that varied!) events, and I submit talks to many CfPs (calls for papers). Whenever this happens, I tend to look back at whether I have any existing talks that I gave and liked and which would be a good fit. I use my speaker page for this: as it's simpler than dredging through my directory of talks/articles on my hard drive (this is now rather large and unmanageable!).

I've recently been thinking that I should also do a better job of linking through to the various talks I'm giving/have given - and at around the same time I was contacted by the good folk at mojoLive about integrating against To cut a long story short, the API now has the functionality for users to retrieve their list of talks!

When you're logged in to using OAuth, a link to your user account appears in the meta information in the footer of each page. You don't need to be logged in for this information, in fact if you run my code, you'll see my results. Either way you'll need the URI for your user on the API; I grabbed that and wrote some simple code to pull my talks. First, I get my user record:

$user = ""; $response = json_decode(file_get_contents($user), true);

The file_get_contents() function is the simplest way I know to quickly fetch the content of a URL. It can handle really lovely complicated stuff too, like headers, POST requests, and all the rest, using PHP's stream contexts - but it's the best way I know of making a GET request in PHP, so I use it here.

Note that I'm grabbing the JSON as an array rather than an object, I think it's easier to do all arrays rather than a mixture of objects and arrays, but it's a matter of taste.

I then select the talks_uri and request the data on that page. Since I didn't specify the format, the service defaults to JSON and I again decode it. I can iterate over the resulting array to pull out all my talks:

$talks_url= $response['users'][0]['talks_uri']; $talks = json_decode(file_get_contents($talks_url), true); if(!empty($talks) && is_array($talks)) { foreach("/

Truncated by Planet PHP, read more at the original (another 1752 bytes)