-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a2c0652
commit c7fc994
Showing
2 changed files
with
96 additions
and
30 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,56 @@ | ||
# Run Async Requests to Outscraper API | ||
|
||
The example shows how to send async requests to Outscraper API and retrieve the results later using request IDs (the requests are processed in parallel). | ||
|
||
## Installation | ||
|
||
### Composer | ||
|
||
You can install the bindings via [Composer](http://getcomposer.org/). Run the following command: | ||
|
||
```bash | ||
composer require outscraper/outscraper | ||
``` | ||
|
||
To use the bindings, use Composer's [autoload](https://getcomposer.org/doc/01-basic-usage.md#autoloading): | ||
|
||
```php | ||
require_once('vendor/autoload.php'); | ||
``` | ||
|
||
### Manual Installation | ||
|
||
If you do not wish to use Composer, you can download the [latest release](https://github.com/outscraper/outscraper-php/releases). Then, to use the bindings, include the `init.php` file. | ||
|
||
```php | ||
require_once('/path/to/outscraper-php/init.php'); | ||
``` | ||
[Link to the PHP package page](https://packagist.org/packages/outscraper/outscraper) | ||
|
||
## Initialization | ||
```php | ||
$client = new OutscraperClient("SECRET_API_KEY"); | ||
``` | ||
[Link to the profile page to create the API key](https://app.outscraper.com/profile) | ||
|
||
## Usage | ||
|
||
```php | ||
$place_ids = array( | ||
'ChIJNw4_-cWXyFYRF_4GTtujVsw', | ||
'ChIJ39fGAcGXyFYRNdHIXy-W5BA', | ||
'ChIJVVVl-cWXyFYRQYBCEkX0W5Y', | ||
'ChIJScUP1R6XyFYR0sY1UwNzq-c', | ||
'ChIJmeiNBMeXyFYRzQrnMMDV8Jc', | ||
'ChIJifOTBMeXyFYRmu3EGp_QBuY', | ||
'ChIJ1fwt-cWXyFYR2cjoDAGs9UI', | ||
'ChIJ5zQrTzSXyFYRuiY31iE7M1s', | ||
'ChIJQSyf4huXyFYRpP9W4rtBelA', | ||
'ChIJRWK5W2-byFYRiaF9vVgzZA4' | ||
); | ||
|
||
foreach ($place_ids as &$place_id) { | ||
$response = $client->google_maps_search([$place_id], language: 'en', region: 'us', async_request: TRUE); | ||
print_r($response['id']); | ||
} | ||
``` |
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