Skip to content

Commit

Permalink
Merge pull request #423 from FlorisDerks/v3.x
Browse files Browse the repository at this point in the history
#421 Update alternative user-agent + also retry for 400 response code, fixes v3 Twitter issue
  • Loading branch information
oscarotero committed Dec 24, 2020
2 parents 0ba0aab + af2691e commit 99f6d95
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Http/CurlDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ public function dispatch(Url $url)

$response = $this->exec($url, $options);

//Some sites returns 403 with the default user-agent
if ($response->getStatusCode() === 403) {
$options[CURLOPT_USERAGENT] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36';
//Some sites returns 400 or 403 with the default user-agent
if ($response->getStatusCode() === 400 || $response->getStatusCode() === 403) {
$options[CURLOPT_USERAGENT] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36';

return $this->exec($url, $options);
}
Expand Down

0 comments on commit 99f6d95

Please sign in to comment.