Media Web Service

Delivering CSUN Individuals Media Information

Introduction

The Media Web Service leverages NameCoach to retrieve an individual’s profile image and their pre-recorded name pronunciation. The web service provides a gateway via a REST-ful API. The information is retrieved by creating a specific URI and giving values to filter the data. The information that is returned is a JSON object that contains media information of a particular CSUN individual. The format of the JSON object is as follows:

{
    "success": "true",
    "status": "200",
    "api": "media",
    "version": "1.1",
    "collection": "media",
    "count": "3",
    "media": [
        {
            "audio_recording": "https://api.sandbox.csun.edu/metalab/media/1.1/faculty/media/nr_steven.fitzgerald/audio-recording",
            "avatar_image": "https://api.sandbox.csun.edu/metalab/media/1.1/faculty/media/nr_steven.fitzgerald/avatar-image",
            "photo_id_image": "https://api.sandbox.csun.edu/metalab/media/1.1/faculty/media/nr_steven.fitzgerald/photo-id-image"
        }
    ]
}

Getting Started

  1. GENERATE THE URI: Find the usage that fits your need. Browse through subcollections, instances and query types to help you craft your URI.
  2. PROVIDE THE DATA: Use the URI to query your data. See the Usage Example session.
  3. SHOW THE RESULTS

Loop through the data to display its information. See the Usage Example section.


Collections

All Persons Media Listing

Subcollections

Specific Media Retrieval Raw Resource Retrieval

Code Samples

                        
//construct a function to get url and iterate over
$(document).ready(function() {
    //generate a url
    var url = 'https://api.sandbox.csun.edu/metalab/media/1.1/faculty/media/nr_steven.fitzgerald/avatar';
    //use the URL as a request
    $.ajax({
        url: url
    }).done(function(data) {
        // print the image url
        console.log(data.avatar_image);
    });
});
                        
                    

                        
//generate a url
$url = 'https://api.sandbox.csun.edu/metalab/media/1.1/faculty/media/nr_steven.fitzgerald/avatar';

//add extra necessary
$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
echo $data['avatar_image'];
                        
                    

                        
#python
import urllib2
import json

#generate a url
url = u'https://api.sandbox.csun.edu/metalab/media/1.1/faculty/media/nr_steven.fitzgerald/avatar'

#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
print data['avatar_image']
                        
                    

                        
require 'net/http'
require 'json'

#generate a url
source = 'https://api.sandbox.csun.edu/metalab/media/1.1/faculty/media/nr_steven.fitzgerald/avatar'

#prepare the uri
uri = URI.parse(source)

#request the data
response = Net::HTTP.get(uri)

#parse the json
data = JSON.parse(response)

#print the value
puts "#{data['avatar_image']}"