/** * HTTP REQUEST */ public function _http($uri, $options = array()) { if ($this->auth->session) { $options['cookies'][] = array('fuelly_session', $this->auth->session); } $url = $this->_url($uri, $options); $log = array(); $log['req'] = $options['method'] . ' ' . $url; $this->log[] =& $log; $_start = microtime(1); $request = HTTP::create($url, $options); $response = $request->request(); $_time = microtime(1) - $_start; $log['rsp'] = $response->code . ' ' . $response->status; $log['time'] = $_time; return $response; }
<?php use rdx\http\HTTP; header('Content-type: text/plain; charset=utf-8'); require 'vendor/autoload.php'; require 'inc.functions.php'; $username = (string) @$_GET['user'] ?: 'instagram'; // 1. Overview $url = 'https://www.instagram.com/' . urlencode($username) . '/'; $request = HTTP::create($url); $response = $request->request(); // 2. Extract JSON if (!preg_match('#>\\s*window._sharedData\\s*=\\s*(\\{.+?)</script>#', $response->body, $match)) { exit("Can't extract any JSON. Wrong URL? {$url}"); } $json = trim($match[1], ' ;'); $data = json_decode($json, true); if (!isset($data['entry_data']['ProfilePage'][0]['user'])) { exit("Can't extract profile JSON. Invalid profile?"); } $profile = $data['entry_data']['ProfilePage'][0]['user']; if (!isset($profile['media']['nodes'])) { exit("Can't extract media JSON. Private profile?"); } $media = $profile['media']['nodes']; // 3. Print RSS header('Content-type: text/xml; charset=utf-8'); echo '<?xml version="1.0" encoding="utf-8"?>' . "\n"; ?> <rss version="2.0"> <channel>