-
-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #369 from denniszon/fix/v3.x/twitter
Add twitter adapter to prevent errors on 429 status code
- Loading branch information
Showing
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace Embed\Adapters; | ||
|
||
use Embed\Http\Response; | ||
|
||
/** | ||
* Adapter to provide information from twitter. | ||
* Required when twitter returns a 429 status code. | ||
*/ | ||
class Twitter extends Webpage | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static function check(Response $response) | ||
{ | ||
return $response->isValid([200, 429]) && $response->getUrl()->match([ | ||
'*twitter.*', | ||
]); | ||
} | ||
} |