Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support API requests through a proxy #258

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/Instagram.php
Original file line number Diff line number Diff line change
Expand Up @@ -621,10 +621,13 @@ protected function _makeCall($function, $auth = false, $params = null, $method =
break;
}

$jsonData = curl_exec($ch);
// split header from JSON data
// and assign each to a variable
list($headerContent, $jsonData) = explode("\r\n\r\n", $jsonData, 2);
// separate header from JSON data in response
// and assign each to a variable.
// use the last two parts of the exploded response
// as there might be headers of proxies first
$explodedResponse = explode("\r\n\r\n", curl_exec($ch));
$jsonData = json_decode(array_pop($explodedResponse));
$headerContent = array_pop($explodedResponse);

// convert header content into an array
$headers = $this->processHeaders($headerContent);
Expand All @@ -638,7 +641,7 @@ protected function _makeCall($function, $auth = false, $params = null, $method =

curl_close($ch);

return json_decode($jsonData);
return $jsonData;
}

/**
Expand Down