This commit is contained in:
2023-11-24 20:49:19 +08:00
parent ca5219cb93
commit be14f5fdb1
65 changed files with 1991 additions and 2214 deletions

View File

@@ -0,0 +1,43 @@
<?php
namespace App\Helpers\FirstParty\DFS;
use Exception;
use Http;
class DFSSerp
{
public static function liveAdvanced($se, $se_type, $keyword, $location_name, $language_code, $depth, $search_param = null)
{
$api_url = config('dataforseo.url');
$api_version = config('dataforseo.api_version');
$api_timeout = config('dataforseo.timeout');
$query = [
'keyword' => $keyword,
'location_name' => $location_name,
'language_code' => $language_code,
];
if (! is_empty($search_param)) {
$query['search_param'] = $search_param;
}
try {
$response = Http::timeout($api_timeout)->withBasicAuth(config('dataforseo.login'), config('dataforseo.password'))->withBody(
json_encode([(object) $query])
)->post("{$api_url}{$api_version}serp/{$se}/{$se_type}/live/advanced");
if ($response->successful()) {
return $response->body();
}
} catch (Exception $e) {
return null;
}
return null;
}
}