我将向内容api密钥的特殊服务器发送httprequest。 除了“狂饮”包装,有什么办法吗? 我不想使用外部软件包。
下面是代码,在laravel中不起作用
<?php
$request = new HttpRequest();
$request->setUrl('https://api.payping.ir/v1/pay');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'authorization' => 'Bearer xxxxxxxxxxxxxxxxxxxxxxxxx',
'content-type' => 'application/json',
'accept' => 'application/json'
));
$request->setBody('{
"payerName": "string",
"amount": 100,
"payerIdentity": "string",
"returnUrl": "Uri Format For Exam: (http(s)://payping.ir)",
"description": "string",
"clientRefId": "string"
}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}