Skip to content

Commit

Permalink
add webhook
Browse files Browse the repository at this point in the history
  • Loading branch information
vs committed Oct 2, 2023
1 parent e164f03 commit 9b86309
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions outscraper.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
*
* @copyright Outscraper 2021
* @license https://raw.githubusercontent.com/outscraper/outscraper-php/main/LICENSE
* @version Release: 3.0.0
* @version Release: 3.1.0
* @link https://github.com/outscraper/outscraper-php
*/
class OutscraperClient {
public $version = "3.0.0";
public $version = "3.1.0";
private $api_url = "https://api.app.outscraper.com";
private $api_headers;
private $max_ttl = 60 * 60;
Expand Down Expand Up @@ -109,18 +109,20 @@ public function get_request_archive(string $request_id) : array {
* @param string $uule Google UULE parameter is used to encode a place or an exact location (with latitude and longitude) into a code. By using it you can see a Google result page like someone located at the specified location.
* @param string $language Parameter specifies the language to use for Google. Available values: "en", "de", "es", "es-419", "fr", "hr", "it", "nl", "pl", "pt-BR", "pt-PT", "vi", "tr", "ru", "ar", "th", "ko", "zh-CN", "zh-TW", "ja", "ach", "af", "ak", "ig", "az", "ban", "ceb", "xx-bork", "bs", "br", "ca", "cs", "sn", "co", "cy", "da", "yo", "et", "xx-elmer", "eo", "eu", "ee", "tl", "fil", "fo", "fy", "gaa", "ga", "gd", "gl", "gn", "xx-hacker", "ht", "ha", "haw", "bem", "rn", "id", "ia", "xh", "zu", "is", "jw", "rw", "sw", "tlh", "kg", "mfe", "kri", "la", "lv", "to", "lt", "ln", "loz", "lua", "lg", "hu", "mg", "mt", "mi", "ms", "pcm", "no", "nso", "ny", "nn", "uz", "oc", "om", "xx-pirate", "ro", "rm", "qu", "nyn", "crs", "sq", "sk", "sl", "so", "st", "sr-ME", "sr-Latn", "su", "fi", "sv", "tn", "tum", "tk", "tw", "wo", "el", "be", "bg", "ky", "kk", "mk", "mn", "sr", "tt", "tg", "uk", "ka", "hy", "yi", "iw", "ug", "ur", "ps", "sd", "fa", "ckb", "ti", "am", "ne", "mr", "hi", "bn", "pa", "gu", "or", "ta", "te", "kn", "ml", "si", "lo", "my", "km", "chr".
* @param string $region Parameter specifies the region to use for Google. Available values: "AF", "AL", "DZ", "AS", "AD", "AO", "AI", "AG", "AR", "AM", "AU", "AT", "AZ", "BS", "BH", "BD", "BY", "BE", "BZ", "BJ", "BT", "BO", "BA", "BW", "BR", "VG", "BN", "BG", "BF", "BI", "KH", "CM", "CA", "CV", "CF", "TD", "CL", "CN", "CO", "CG", "CD", "CK", "CR", "CI", "HR", "CU", "CY", "CZ", "DK", "DJ", "DM", "DO", "EC", "EG", "SV", "EE", "ET", "FJ", "FI", "FR", "GA", "GM", "GE", "DE", "GH", "GI", "GR", "GL", "GT", "GG", "GY", "HT", "HN", "HK", "HU", "IS", "IN", "ID", "IQ", "IE", "IM", "IL", "IT", "JM", "JP", "JE", "JO", "KZ", "KE", "KI", "KW", "KG", "LA", "LV", "LB", "LS", "LY", "LI", "LT", "LU", "MG", "MW", "MY", "MV", "ML", "MT", "MU", "MX", "FM", "MD", "MN", "ME", "MS", "MA", "MZ", "MM", "NA", "NR", "NP", "NL", "NZ", "NI", "NE", "NG", "NU", "MK", "NO", "OM", "PK", "PS", "PA", "PG", "PY", "PE", "PH", "PN", "PL", "PT", "PR", "QA", "RO", "RU", "RW", "WS", "SM", "ST", "SA", "SN", "RS", "SC", "SL", "SG", "SK", "SI", "SB", "SO", "ZA", "KR", "ES", "LK", "SH", "VC", "SR", "SE", "CH", "TW", "TJ", "TZ", "TH", "TL", "TG", "TO", "TT", "TN", "TR", "TM", "VI", "UG", "UA", "AE", "GB", "US", "UY", "UZ", "VU", "VE", "VN", "ZM", "ZW".
* @param bool $webhook Parameter defines the URL address (callback) to which Outscraper will create a POST request with a JSON body once a task/request is finished. Using this parameter overwrites the webhook from integrations.
*
* @return array request/task result
*/
public function google_search(
string|array $query, int $pages_per_query = 1, string $uule = "", string $language = "en", string $region = NULL
string|array $query, int $pages_per_query = 1, string $uule = "", string $language = "en", string $region = NULL, string $webhook = NULL
) : array {
$params = http_build_query(array(
"query" => $this->to_array($query),
"pagesPerQuery" => $pages_per_query,
"uule" => $uule,
"language" => $language,
"region" => $region
"region" => $region,
"webhook" => $webhook,
));
$result = $this->make_get_request("google-search-v3?{$params}");
return $result["data"];
Expand All @@ -138,12 +140,13 @@ public function google_search(
* @param bool $drop_duplicates Parameter specifies whether the bot will drop the same organizations from different queries. Using the parameter combines results from each query inside one big array.
* @param int $skip Skip first N places, where N should be multiple to 20 (e.g. 0, 20, 40). It's commonly used in pagination.
* @param bool $async_request Parameter defines the way you want to submit your task to Outscraper. It can be set to `False` (default) to send a task and wait until you got your results, or `True` to submit your task and retrieve the results later using a request ID with `get_request_archive`. Each response is available for `2` hours after a request has been completed.
* @param bool $webhook Parameter defines the URL address (callback) to which Outscraper will create a POST request with a JSON body once a task/request is finished. Using this parameter overwrites the webhook from integrations.
*
* @return array request/task result
*/
public function google_maps_search(
string|array $query, string $language = "en", string $region = NULL, int $limit = 400,
string $coordinates = NULL, bool $drop_duplicates = FALSE, int $skip = 0, bool $async_request = FALSE
string $coordinates = NULL, bool $drop_duplicates = FALSE, int $skip = 0, bool $async_request = FALSE, string $webhook = NULL
) : array|string {
$params = http_build_query(array(
"query" => $this->to_array($query),
Expand All @@ -154,6 +157,7 @@ public function google_maps_search(
"dropDuplicates" => $drop_duplicates,
"skipPlaces" => $skip,
"async" => $async_request,
"webhook" => $webhook,
));
$result = $this->make_get_request("maps/search-v2?{$params}");

Expand Down Expand Up @@ -207,13 +211,14 @@ public function google_maps_search_v1(
* @param string $sort Parameter specifies one of the sorting types. Available values: "most_relevant", "newest", "highest_rating", "lowest_rating".
* @param string $reviews_query Parameter specifies the query to search among the reviews (e.g. wow, amazing, horrible place).
* @param bool $async_request Parameter defines the way you want to submit your task to Outscraper. It can be set to `False` (default) to send a task and wait until you got your results, or `True` to submit your task and retrieve the results later using a request ID with `get_request_archive`. Each response is available for `2` hours after a request has been completed.
* @param bool $webhook Parameter defines the URL address (callback) to which Outscraper will create a POST request with a JSON body once a task/request is finished. Using this parameter overwrites the webhook from integrations.
*
* @return array request/task result
*/
public function google_maps_reviews(
string|array $query, string $language = "en", string $region = NULL, int $limit = 1,
int $reviews_limit = 100, string $coordinates = NULL, int $cutoff = NULL, int $cutoff_rating = NULL,
string $sort = "most_relevant", string $reviews_query = NULL, bool $async_request = FALSE
string $sort = "most_relevant", string $reviews_query = NULL, bool $async_request = FALSE, string $webhook = NULL
) : array|string {
$params = http_build_query(array(
"query" => $this->to_array($query),
Expand All @@ -227,6 +232,7 @@ public function google_maps_reviews(
"reviewsQuery" => $reviews_query,
"sort" => $sort,
"async" => $async_request,
"webhook" => $webhook,
));
$result = $this->make_get_request("maps/reviews-v3?{$params}");

Expand Down

0 comments on commit 9b86309

Please sign in to comment.