Code Examples: PHP

Our code examples use the Trstrank API, the most popular API on Infochimps.

infochimps-trstrank.php

  <? 
  $apikey = 'api_test-W1cipwpcdu9Cbd9pmm8D4Cjc469';
  $screen_name = 'infochimps';
  $uri = file_get_contents("http://api.infochimps.com/soc/net/tw/trstrank.json?".
    "apikey=".$apikey.
    "&screen_name=".$screen_name,
    true); 

  $obj = json_decode($uri); // Convert JSON

  echo $obj->screen_name .': '. $obj->trstrank;
?>

Usage

Enter the following command into the command line to run.

  // requires php5-cli to run on command line
php infochimps-api-json.php
// => infochimps: 3.69686