Skip to content

Instantly share code, notes, and snippets.

@adamdilek
Created December 21, 2011 13:51
Show Gist options
  • Save adamdilek/1506129 to your computer and use it in GitHub Desktop.
Save adamdilek/1506129 to your computer and use it in GitHub Desktop.
PHP Example for University API
<?php header("content-type: text/html; charset=utf-8"); ?>
<?php
function get($request){
$session=curl_init($request);
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$response=curl_exec($session);
curl_close($session);
return json_decode($response);
}
$universities=get("http://pigon.ws/university/list");
foreach($universities as $university) {
echo $university->id;
echo $university -> name;
echo "<br>";
$faculties=get("http://pigon.ws/university/faculties?university_id=".$university->id);
foreach($faculties as $faculty) {
echo "-";
echo $faculty->id;
echo $faculty->name;
echo "<br>";
$departments=get("http://pigon.ws/university/departments?faculty_id=".$faculty->id);
foreach($departments as $department) {
echo "--";
echo $department->name;
echo "<br>";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment