Delivering Degree information about CSUN Faculty
DOCUMENTATION
VERSION HISTORY
{
appt_year: "1994",
degrees: [
{
"degree": "Ph.D.",
"year": "2008",
"institute": "University of California Los Angeles",
},
{
"degree": "M.S.",
"year": "2003",
"institute": "University of California Los Angeles",
},
{
"degree": "B.S.",
"year": "2000",
"institute": "University of California Los Angeles",
}
]
}
//construct a function to get url and iterate over
$(document).ready(function() {
//generate a url
var url = 'https://www.csun.edu/web-dev/api/degrees/degrees/degrees?person=steven.fitzgerald@csun.edu';
//use the URL as a request
$.ajax({
url: url
}).done(function(data) {
// save the degree list
var degreeList = data.degrees;
//iterate over the degree list
$(degreeList).each(function(index, degree) {
//append each degree and institute
$('#degree-results').append(degree.degree + ' ' + degree.institute + '<br>');
});
});
});
//generate a url
$url = 'https://www.csun.edu/web-dev/api/degrees/degrees/degrees?person=steven.fitzgerald@csun.edu';
//add extra necessary options
$arrContextOptions = [
"ssl" => [
"verify_peer"=>false,
"verify_peer_name"=>false
]
];
//perform the query
$data = file_get_contents($url, false, stream_context_create($arrContextOptions));
//decode the json
$data = json_decode($data, true);
//iterate over the list of data and print
foreach($data['degrees'] as $degree){
echo = $degree['degree'] . ' ' . $degree['institute'].'<br>';
}
#python
import urllib2
import json
#generate a url
url = u'https://www.csun.edu/web-dev/api/degrees/degrees/degrees?person=steven.fitzgerald@csun.edu'
#open the url
try:
u = urllib2.urlopen(url)
data = u.read()
except Exception as e:
data = {}
#load data with json object
data = json.loads(data)
#iterate over the json object and print
for degree in data['degrees']:
print degrees['degree'] + ' ' + degrees['institute']
require 'net/http'
require 'json'
#generate a url
source = 'https://www.csun.edu/web-dev/api/degrees/degrees/degrees?person=steven.fitzgerald@csun.edu'
#prepare the uri
uri = URI.parse(source)
#request the data
response = Net::HTTP.get(uri)
#parse the json
degrees = JSON.parse(response)
#print the json
degrees['degrees'].each do |degree|
puts "#{degree['degree']} #{degree['institute']}"