This commit is contained in:
2023-11-26 18:56:40 +08:00
parent be14f5fdb1
commit 64431e7a73
144 changed files with 497072 additions and 3730 deletions

View File

@@ -0,0 +1,44 @@
<?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 = DFSCommon::getApiUrl();
$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;
}
}