Skip to content

Commit

Permalink
remove file stream support
Browse files Browse the repository at this point in the history
  • Loading branch information
kringkaste committed Jul 16, 2021
1 parent c6ecf4f commit 00f5475
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 25 deletions.
3 changes: 0 additions & 3 deletions src/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
// Timeout in seconds waiting for the Instagram page to load.
'timeout' => 5,

// Use Guzzle instead of php's file stream
'useGuzzle' => false,

// Dump Instagram response to file for debugging purpose
'dump' => false,

Expand Down
3 changes: 2 additions & 1 deletion src/models/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class Settings extends Model
public $timeout = 10;

/**
* @deprecated Guzzle will always be used.
* @var boolean Use Guzzle instead of php's file stream to fetch the Instagram page
*/
public $useGuzzle = false;
Expand Down Expand Up @@ -66,7 +67,7 @@ public function rules()
return [
[['instagramUser', 'timeout', 'userAgent'], 'required'],
['timeout', 'double', 'min' => 1],
[['useGuzzle', 'useProxy', 'useVolume'], 'boolean'],
[['useProxy', 'useVolume'], 'boolean'],
['dump', 'boolean'],
[['userAgent', 'proxyKey', 'volume', 'subpath'], 'string'],
];
Expand Down
21 changes: 0 additions & 21 deletions src/services/InstagramService.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,27 +237,6 @@ private function fetchInstagramPage(string $path): string
$userAgent = $settings->userAgent !== '' ? $settings->userAgent : $defaultUserAgent;
}

if (!$settings->useGuzzle) {
Craft::debug('Using php file stream to fetch Instagram page.', __METHOD__);

$streamOptions = [
'http' => [
'timeout' => $settings->timeout,
'header' => "Accept-Language: en-US;q=0.9,en;q=0.8\r\nUser-Agent: " . $userAgent . "\r\n",
],
];

if ($settings->useProxy && $settings->proxyKey !== '') {
$streamOptions['http']['header'] .= 'Authorization: ' . $settings->proxyKey . "\r\n";
}

$context = stream_context_create($streamOptions);

return @file_get_contents($url, false, $context);
}

Craft::debug('Using Guzzle to fetch Instagram page.', __METHOD__);

$client = new Client();

$guzzleOptions = [
Expand Down

0 comments on commit 00f5475

Please sign in to comment.