You can do http requests using the Curl library and decode the JSON result with json_decode() function. PHP 5.2 and above comes with the JSON library functions.
The following example will send a request using curl to a video library api and extract links to the video thumbnail images. The result will be a list of links to thumbnail images in a json data format. The json_decode() function will then convert the json object into an associative array and will finally print out the links. This is all done within the php script.
<?php
//check if you have curl loaded
if(!function_exists("curl_init")) die("cURL extension is not installed");
$url = 'http://api.brightcove.com/services/library?command=find_all_videos'.
'&video_fields=thumbnailURL&token=0Z2dtxTdJAxtbZ-d0U7Bhio2V1Rhr5Iafl5FFtDPY8E.';
$ch=curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$r=curl_exec($ch);
curl_close($ch);
$arr = json_decode($r,true);
foreach($arr['items'] as $val)
{
echo $val['thumbnailURL'].'<br>';
}
0 Comments.