fixed kilo in metals 6
This commit is contained in:
@@ -73,6 +73,26 @@ class Controller extends BaseController
|
||||
return $formatted !== '' ? $formatted : '0';
|
||||
}
|
||||
|
||||
/**
|
||||
* گزینههای Guzzle/cURL — فقط وقتی افزونه curl و ثابتها موجود باشند.
|
||||
*
|
||||
* @param array<int, mixed> $curlOptions
|
||||
* @return array<string, array<int, mixed>>
|
||||
*/
|
||||
public static function httpClientOptions(array $curlOptions = []): array
|
||||
{
|
||||
$curl = $curlOptions;
|
||||
|
||||
if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) {
|
||||
$resolveOpt = (int) constant('CURLOPT_IPRESOLVE');
|
||||
if (! array_key_exists($resolveOpt, $curl)) {
|
||||
$curl[$resolveOpt] = (int) constant('CURL_IPRESOLVE_V4');
|
||||
}
|
||||
}
|
||||
|
||||
return $curl === [] ? [] : ['curl' => $curl];
|
||||
}
|
||||
|
||||
public static function Send($to , $msg, $is_customer = true)
|
||||
{
|
||||
$r = self::SendMessage($to , $msg, $is_customer);
|
||||
@@ -139,26 +159,32 @@ class Controller extends BaseController
|
||||
]);
|
||||
$platforms[] = "0098:{$to}";*/
|
||||
|
||||
$response = Http::timeout(15)
|
||||
->withHeaders([
|
||||
'Content-Type' => 'application/json',
|
||||
'secret_key' => 'f21debfb-83ac-4624-a2f4-f08375043181',
|
||||
])
|
||||
->withOptions([
|
||||
'curl' => [
|
||||
\CURLOPT_IPRESOLVE => \CURL_IPRESOLVE_V4,
|
||||
]
|
||||
])
|
||||
->post('http://185.231.112.101/api/createsms', [
|
||||
try {
|
||||
$http = Http::timeout(15)
|
||||
->withHeaders([
|
||||
'Content-Type' => 'application/json',
|
||||
'secret_key' => 'f21debfb-83ac-4624-a2f4-f08375043181',
|
||||
]);
|
||||
|
||||
$curlOptions = self::httpClientOptions();
|
||||
if ($curlOptions !== []) {
|
||||
$http = $http->withOptions($curlOptions);
|
||||
}
|
||||
|
||||
$response = $http->post('http://185.231.112.101/api/createsms', [
|
||||
'phone' => $to,
|
||||
'host' => $config->Config('name_fa') ?? gethostname(),
|
||||
'text' => trim($msg),
|
||||
'platform' => 'rayegansms',
|
||||
]);
|
||||
|
||||
$platforms[] = $response->successful()
|
||||
? "rayegansms:{$to}"
|
||||
: "rayegansms_failed:{$to}:{$response->status()}";
|
||||
$platforms[] = $response->successful()
|
||||
? "rayegansms:{$to}"
|
||||
: "rayegansms_failed:{$to}:{$response->status()}";
|
||||
} catch (\Throwable $e) {
|
||||
report($e);
|
||||
$platforms[] = "rayegansms_error:{$to}";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user