hxd
parent
fa4d15eca9
commit
c6284089a3
@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
namespace Org\Outer;
|
||||||
|
|
||||||
|
use Base\Tool\Log;
|
||||||
|
use Exception;
|
||||||
|
use Think\Log as ThinkLog;
|
||||||
|
|
||||||
|
class OuterApi
|
||||||
|
{
|
||||||
|
public static function request($params)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$response = self::post('http://wap.hexidongkeji.top/pay', $params);
|
||||||
|
self::log('REQUEST_RESPONSE: ' . $response);
|
||||||
|
return json_decode($response, true);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
self::log('REQUEST_ERROR: ' . $e->getMessage());
|
||||||
|
return [
|
||||||
|
'code' => -999,
|
||||||
|
'message' => '网络错误',
|
||||||
|
'data' => null,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function post($url, $params)
|
||||||
|
{
|
||||||
|
self::log('REQUEST_URL: ' . $url);
|
||||||
|
self::log('REQUEST_DATA: ' . json_encode($params));
|
||||||
|
$curl = curl_init();
|
||||||
|
if (stripos($url, 'https://') !== false){
|
||||||
|
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||||
|
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
|
||||||
|
}
|
||||||
|
curl_setopt($curl, CURLOPT_URL, $url);
|
||||||
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
||||||
|
curl_setopt($curl, CURLOPT_POST, true);
|
||||||
|
$headers = ['Content-type: application/json'];
|
||||||
|
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
||||||
|
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($params));
|
||||||
|
$response = curl_exec($curl);
|
||||||
|
curl_close($curl);
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function log($content, $level = ThinkLog::INFO) {
|
||||||
|
Log::write($content, $level, 'outer_pay');
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue