@ 2018-01-29T21:28:40Z <?php
/*
* Instagram's proxy API
* reads Instagram pages and gets embedded data,
* then returns it as json or jsonp.
* By Francisco Diaz :: picssel.com
* Revision March 2015
*/ /*$sawOrigin = false;
$originHeader = $_SERVER['HTTP_ORIGIN'];
$originHeader = isset($_SERVER['HTTP_ORIGIN']) ? $_SERVER['HTTP_ORIGIN'] : null;
if ($originHeader) {
echo "Origin header value: $originHeader";
}*/
/***** get request origin and set domain restrictions *****/
$HTTP_ORIGIN = $_SERVER['HTTP_ORIGIN'];
// 1). ALL domains
// header("Access-Control-Allow-Origin: *");
// 2). Single domain
/*
if ($HTTP_ORIGIN == "http://www.picssel.com"){
header("Access-Control-Allow-Origin: $HTTP_ORIGIN");
}
*/
// 3). Several domains, e.g. http://picssel.com, http://fiddle.jshell.net, etc.
$domains_allowed = array("http://www.picssel.com", "http://www.picssel.ca");
if(in_array( $HTTP_ORIGIN, $domains_allowed )){
header("Access-Control-Allow-Origin: $HTTP_ORIGIN");
}
/***** functions *****/
// sanitize input
function sanitize_input($input){
$input = trim($input);
$input = stripslashes($input);
$input = strip_tags($input);
$input = htmlspecialchars($input);
return $input;
};
// process data
function process_data($dataFile, $requestType){
$data_length = strlen($dataFile);
if( $data_length > 0 ){
$start_position = strpos( $dataFile ,'{"static_root"' ); // start position
$trimmed_before = trim( substr($dataFile, $start_position) ); // trim preceding content
$end_position = strpos( $trimmed_before, '</script>'); // end position
$trimmed = trim( substr( $trimmed_before, 0, $end_position) ); // trim content
$jsondata = substr( $trimmed, 0, -1); // remove extra trailing ";"
header("HTTP/1.0 200 OK");
// JSONP response
if(array_key_exists('callback', $_GET)){
header('Content-Type: text/javascript; charset=utf8');
$callback = $_GET['callback'];
return $callback."(".$jsondata.");";
}
// JSON response
else {
header('Content-Type: application/json; charset=utf-8');
return $jsondata;
}
} else {
// invalid username or media
header("HTTP/1.0 400 BAD REQUEST");
header('Content-Type: text/html; charset=utf-8');
die("invalid $requestType");
}
};
/***** Get user's input *****/
$user = sanitize_input( $_GET['user'] ); // expects something like "instagram" (username)
$media = sanitize_input( $_GET['media'] ); // expects something like "mOFsFhAp4f" (shortcode)
/***** set context *****/
$context = stream_context_create(array(
'http' => array(
'timeout' => 10 // in seconds
)
)
);
/***** validate request type and return response *****/
// user, including last 20 media posts
if( !empty($user) && empty($media) ){
$requestType = "user";
$dataFile = @ file_get_contents("http://instagram.com/".$user, NULL, $context);
echo process_data($dataFile, $requestType);
}
// media
elseif( empty($user) && !empty($media) ){
$requestType = "media";
$dataFile = @ file_get_contents("http://instagram.com/p/".$media, NULL, $context);
echo process_data($dataFile, $requestType);
}
// invalid : two or more parameters were passed
elseif( !empty($user) && !empty($media) ){
header("HTTP/1.0 400 BAD REQUEST");
header('Content-Type: text/html; charset=utf-8');
die("only one parameter allowed");
}
// invalid : none or invalid parameters were passed
elseif( empty($user) && empty($media) ){
header("HTTP/1.0 400 BAD REQUEST");
header('Content-Type: text/html; charset=utf-8');
die("invalid parameters");
};
?>
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 8.3.6 0.011 0.004 18.40 8.3.5 0.013 0.006 18.20 8.3.4 0.012 0.003 18.72 8.3.3 0.006 0.009 18.85 8.3.2 0.008 0.000 20.37 8.3.1 0.004 0.004 23.71 8.3.0 0.005 0.003 19.26 8.2.18 0.015 0.004 18.29 8.2.17 0.010 0.006 22.96 8.2.16 0.011 0.004 19.45 8.2.15 0.008 0.000 24.18 8.2.14 0.005 0.003 24.66 8.2.13 0.005 0.003 21.11 8.2.12 0.004 0.004 26.35 8.2.11 0.005 0.005 22.26 8.2.10 0.007 0.004 17.91 8.2.9 0.004 0.004 20.60 8.2.8 0.003 0.005 17.97 8.2.7 0.000 0.009 18.05 8.2.6 0.000 0.008 18.12 8.2.5 0.003 0.005 18.21 8.2.4 0.004 0.004 20.44 8.2.3 0.007 0.000 19.55 8.2.2 0.007 0.000 18.13 8.2.1 0.000 0.009 18.12 8.2.0 0.000 0.008 18.22 8.1.28 0.009 0.006 25.92 8.1.27 0.008 0.000 20.22 8.1.26 0.005 0.003 26.35 8.1.25 0.000 0.007 28.09 8.1.24 0.007 0.003 20.50 8.1.23 0.010 0.003 17.42 8.1.22 0.006 0.003 17.74 8.1.21 0.005 0.003 18.84 8.1.20 0.003 0.005 17.48 8.1.19 0.007 0.003 17.35 8.1.18 0.003 0.006 18.10 8.1.17 0.008 0.000 18.65 8.1.16 0.007 0.000 18.79 8.1.15 0.000 0.008 20.30 8.1.14 0.003 0.005 17.75 8.1.13 0.003 0.003 18.82 8.1.12 0.000 0.007 17.39 8.1.11 0.009 0.000 17.51 8.1.10 0.004 0.004 17.49 8.1.9 0.004 0.004 17.57 8.1.8 0.000 0.008 17.49 8.1.7 0.007 0.000 17.40 8.1.6 0.005 0.002 17.64 8.1.5 0.000 0.009 17.38 8.1.4 0.006 0.003 17.54 8.1.3 0.004 0.008 17.57 8.1.2 0.002 0.005 17.66 8.1.1 0.004 0.004 17.51 8.1.0 0.003 0.010 17.54 8.0.30 0.004 0.004 20.03 8.0.29 0.003 0.006 16.75 8.0.28 0.000 0.008 18.48 8.0.27 0.007 0.000 17.16 8.0.26 0.004 0.004 16.91 8.0.25 0.005 0.003 17.04 8.0.24 0.007 0.000 17.02 8.0.23 0.003 0.005 17.05 8.0.22 0.000 0.007 16.92 8.0.21 0.007 0.000 17.02 8.0.20 0.000 0.007 17.05 8.0.19 0.002 0.005 16.92 8.0.18 0.000 0.007 17.01 8.0.17 0.004 0.004 16.96 8.0.16 0.003 0.005 17.11 8.0.15 0.003 0.005 16.88 8.0.14 0.004 0.004 16.93 8.0.13 0.006 0.000 13.32 8.0.12 0.004 0.004 16.94 8.0.11 0.000 0.007 16.81 8.0.10 0.004 0.004 16.85 8.0.9 0.004 0.004 16.86 8.0.8 0.004 0.012 17.03 8.0.7 0.008 0.000 16.84 8.0.6 0.000 0.007 16.82 8.0.5 0.000 0.008 16.78 8.0.3 0.012 0.009 17.02 8.0.2 0.011 0.011 17.41 8.0.1 0.000 0.007 17.09 8.0.0 0.008 0.009 16.93 7.4.33 0.005 0.000 15.55 7.4.32 0.004 0.004 16.46 7.4.30 0.000 0.006 16.54 7.4.29 0.000 0.007 16.50 7.4.28 0.007 0.000 16.55 7.4.27 0.004 0.004 16.53 7.4.26 0.004 0.004 16.38 7.4.25 0.008 0.000 16.48 7.4.24 0.000 0.007 16.49 7.4.23 0.000 0.007 16.65 7.4.22 0.004 0.004 16.64 7.4.21 0.006 0.009 16.46 7.4.20 0.000 0.007 16.62 7.4.16 0.008 0.010 16.48 7.4.15 0.014 0.005 17.40 7.4.14 0.013 0.006 17.86 7.4.13 0.012 0.006 16.61 7.4.12 0.016 0.004 16.62 7.4.0 0.007 0.003 16.40 7.3.33 0.000 0.008 13.23 7.3.32 0.000 0.006 13.26 7.3.31 0.007 0.000 16.30 7.3.30 0.004 0.004 16.35 7.3.29 0.006 0.010 16.36 7.3.28 0.007 0.007 16.41 7.3.27 0.009 0.009 17.40 7.3.26 0.009 0.010 16.46 7.3.25 0.011 0.007 16.48 7.3.24 0.010 0.013 16.45 7.2.1 0.017 0.005 17.93 5.4.0 0.003 0.003 13.11
preferences:dark mode live preview
61.96 ms | 401 KiB | 5 Q