<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>Derick Rethans - tag: talks</title>
    <link>http://derickrethans.nl/feed-talks.xml</link>
    <description>This feed shows the latest 15 items with the tag talks</description>
    <language>en-us</language>
    <copyright>All rights reserved - Derick Rethans</copyright>
    <managingEditor>derick@derickrethans.nl (Derick Rethans)</managingEditor>
    <pubDate>Thu, 20 Jan 2011 23:18:37 +0000</pubDate>
    <lastBuildDate>Thu, 20 Jan 2011 23:18:37 +0000</lastBuildDate>
    <generator>eZ Components Feed dev (http://ezcomponents.org/docs/tutorials/Feed)</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>60</ttl>
    <item>
      <title>Joind.in's API</title>
      <link>http://derickrethans.nl/joindins-api.html</link>
      <description>&lt;div class="article"&gt;
  &lt;div class="body"&gt;
    &lt;div class="articleListItem"&gt;
      &lt;h1&gt;&lt;a name="joind_in_s_api"/&gt;Joind.in's API&lt;/h1&gt;
      &lt;dl class="head"/&gt;
      &lt;div class="articleMetaData"&gt;
        &lt;div class="location"&gt; London, UK&lt;/div&gt;
        &lt;div class="date"&gt;Friday, February 12th 2010, 22:27 GMT&lt;/div&gt;
      &lt;/div&gt;
      &lt;p&gt;I speak at many &lt;a href="http://derickrethans.nl/talks.html"&gt;conferences&lt;/a&gt; and more and more of those conferences are using a service called &lt;a href="http://joind.in"&gt;joind.in&lt;/a&gt;. The joind.in website allows attendees of conferences to leave feedback for the speakers, organisers and sponsors. For me as a &lt;a href="http://joind.in/user/view/30"&gt;speaker&lt;/a&gt; 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.&lt;/p&gt;
      &lt;p&gt;The joind.in website also provides an &lt;a href="http://joind.in/api"&gt;API&lt;/a&gt; that allows you to talk to the service from other applications and sites. I've now integrated this in my site (at the &lt;a href="http://derickrethans.nl/talks.html"&gt;talks&lt;/a&gt; page). It uses &lt;a href="http://api.jquery.com/category/ajax/"&gt;JQuery's ajax&lt;/a&gt; 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 &lt;code&gt;http://joind.in/api/talk&lt;/code&gt; for requesting information about talks, and &lt;code&gt;http://joind.in/api/user&lt;/code&gt; for fetching information about users.&lt;/p&gt;
      &lt;p&gt;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:&lt;/p&gt;
      &lt;pre&gt;&lt;?php
$id = 1240;

$requestData = &lt;&lt;&lt;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 )
{
        /* ... */
}
?&gt;


&lt;/pre&gt;
      &lt;p&gt;The &lt;code&gt;do_post_request()&lt;/code&gt; code I lifted from &lt;a href="http://netevil.org/blog/2006/nov/http-post-from-php-without-curl"&gt;Wez'&lt;/a&gt; page, and looks like:&lt;/p&gt;
      &lt;pre&gt;&lt;?php
function do_post_request($url, $data, $optional_headers = null)
{
        $params = array(
                'http' =&gt; array(
                        'method' =&gt; 'POST',
                        'content' =&gt; $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;
}
?&gt;

&lt;/pre&gt;
      &lt;p&gt;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' &lt;a href="http://ezcomponents.org/s/Cache"&gt;Cache&lt;/a&gt; component.&lt;/p&gt;
      &lt;p&gt;You can see the code operational on the &lt;a href="http://derickrethans.nl/talks.html"&gt;talks&lt;/a&gt; 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.&lt;/p&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
</description>
      <guid>201002122227</guid>
      <pubDate>Fri, 12 Feb 2010 22:27:00 +0000</pubDate>
    </item>
  </channel>
</rss>

