Skip to content

Instantly share code, notes, and snippets.

@ManishLSN
Created March 27, 2017 07:23
Show Gist options
  • Save ManishLSN/5ec312b9ec5c103bbdd4129513aa8908 to your computer and use it in GitHub Desktop.
Save ManishLSN/5ec312b9ec5c103bbdd4129513aa8908 to your computer and use it in GitHub Desktop.
<?php
function processURL($url){
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => 2
));
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
$contentLibrary["name"] = 'tango_tarun'; //'poojajain__'; // 'manishjaincool';
$url = 'https://www.instagram.com/'.$contentLibrary["name"].'/media/';
$response = array();
$data = json_decode(processURL($url), true);
if(isset($data["status"]) && $data["status"] == "ok"){
foreach($data["items"] as $item){
$response[] = array("src" => $item[$item["type"]."s"]["standard_resolution"]["url"], "type" => $item["type"]);
}
}
echo "<pre>"; print_r($response);
foreach($response as $node){
if(isset($node["type"]) && $node["type"] === "video"){
?>
<video controls >
<source src="<?php echo $node["src"]; ?>" type="video/mp4">
<source src="movie.ogg" type="video/ogg"> Your browser does not support the video tag.
</video>
<?php
// $response[] = array("src" => $node["video_url"], "type" => "video");
}
else{
$src = $node["src"];
echo "<img src=\"$src\" /> <br>";
// $response[] = array("src" => $node["src"], "type" => "image");
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment