This website recently got a major rebuild; if you're missing something, let Lorna know.

Fetching Your Talks from the Joind.In API



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 joind.in speaker page for this: http://joind.in/user/view/110 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 joind.in. To cut a long story short, the joind.in API now has the functionality for users to retrieve their list of talks!

When you're logged in to joind.in 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 = "http://api.joind.in/v2.1/users/110";
$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($talks['talks'] as $talk) {
        echo $talk['talk_title'] . "\n";
    }
}

By default I get the most recent 20 records but you can change the start and resultsperpage parameters on the URL if you want more or fewer results, and resultsperpage=0 will give you everything, with no limit on the number of records (which is probably fine for your talks). This script would make a nice basis for a speaker to add their most recent talks to their website, or to power their own "speaker's CV" perhaps - or to allow mojoLive to give you involvement points for the talks you've given without you re-entering all that data manually. Enjoy :)


In: php
Tags: #api #joind.in