Joind.in's API
I speak at many conferences and more and more of those conferences are using a service called joind.in. The joind.in website allows attendees of conferences to leave feedback for the speakers, organisers and sponsors. For me as a speaker this feedback by attendees is very important (as long as the comments are constructive). I use those comments to tweak and improve my presentations if I give them at a later moment.
The joind.in website also provides an API that allows you to talk to the service from other applications and sites. I've now integrated this in my site (at the talks page). It uses JQuery's ajax functionality to talk to the backend which queries (and caches) the joind.in API requests. In order to make API calls, you need to make POST requests to a specific URL. The URL depends on what type of object you want to use. For example, there is http://joind.in/api/talk for requesting information about talks, and http://joind.in/api/user for fetching information about users.
Requests can be either made in XML, or with JSON. A simple example to request all comments for a specific talk can be done with something like:
<?php
$id = 1240;
$requestData = <<<ENDD
{"request":{
"action":{
"type":"getcomments",
"data":{"talk_id":$id}
}
}}
ENDD;
$data = do_post_request(
'http://joind.in/api/talk',
$requestData,
'Content-type: application/json'
);
foreach( json_decode( $data ) as $comment )
{
/* ... */
}
?>
The do_post_request() code I lifted from Wez' page, and looks like:
<?php
function do_post_request($url, $data, $optional_headers = null)
{
$params = array(
'http' => array(
'method' => 'POST',
'content' => $data
)
);
if ( $optional_headers !== null) {
$params['http']['header'] = $optional_headers;
}
$ctx = stream_context_create( $params );
$fp = fopen( $url, 'rb', false, $ctx );
$response = stream_get_contents( $fp );
return $response;
}
?>
I am also fetching the full name for each user. Because this could mean that I have to do a lot of requests I am caching them with eZ Components' Cache component.
You can see the code operational on the talks page, by clicking on the little joind.in logo after each talk that is on the site. If JavaScript is disabled, the logo turns into a link that takes you to the joind.in site with all the comments.
Comments
From an application design perspective; given the update ratio of those talks after the event is over, why would you want to do this with ajax (even though you cache things). Wouldn't it be better to do this asynchronously and fetch them regularly using a cron script, and have them available on the spot? Saves the 'fetching from joind.in...' wait time.
@Ivo: I suppose I could. I think there will be so little people actually checking this, that in the current form there will actually be less calls to the joind.in API. It was also a little experiment with JQuery :-)
I didn't even know that joind.in had an API. How long ago was this API introduced?
@Anna: I've no idea really... it's been there for a while. I suppose that makes integrating it easier? :-)
Well I'm glad to see that joind.in has one. I needed it for my event but never got an answer from Chris on that subject. Then I saw your blog post. Thanks!
Interesting that you created a JSON object by hand; why not create it as a normal PHP data structure and then convert it to JSON with json_encode()?
@Ken: No real reason except that it is a bit more clear what happens here. In the most idea case, I should simply have to request (with GET) http://joind.in/api/talk/getcomments/<id> though.
Life Line
Updated a bench and a waste_basket
I walked 8.3km in 1h25m37s
Created a recycling
I walked 10.5km in 1h46m57s
An interesting journey in story form, showing how English changed over time.
https://www.deadlanguagesociety.com/p/how-far-back-in-time-understand-english
A much better writer than I is summing up perfectly why I have such disdain for Generative AI/LLMs.
https://jonn.substack.com/p/so-why-do-i-feel-so-angry-about-this
Created a waste_basket; Updated a waste_basket; Deleted a bench
Created a bench; Updated 7 benches and a gate; Deleted 2 benches and a gate
Created 10 benches and 2 waste_baskets; Updated an information
Created a bench; Updated 2 benches; Deleted a bench
I hiked 18.1km in 3h17m10s
I walked 3.0km in 25m12s
Updated a restaurant
I walked 4.6km in 34m18s
I walked 0.7km in 5m33s
Updated a restaurant
Updated a pub
I walked 12.3km in 2h11m46s
I walked 2.9km in 29m53s
I walked 1.1km in 9m53s
Updated 2 house buildings
Updated 2 estate_agent offices
I walked 8.2km in 1h37m13s
I'm excited about the PHP UK Conference on Friday!
I am speaking on @Xdebug, but the whole programme looks great:
https://www.phpconference.co.uk/scheduleTickets are still available, and you'll get 10% off with the code "PHPUK26".
Will I see you there?


Shortlink
This article has a short URL available: https://drck.me/joind.ins-api-7rl