使用点net或php发送restful请求
我必须向此url发送请求:使用点net或php发送restful请求,php,Php,我必须向此url发送请求: https://pos.go.thispay.com/merchantApi/m 请求内容: [ { "tnumb": null, "request": 5, "limitdetail": null, "publication": null, "merch": { "firsn": "
https://pos.go.thispay.com/merchantApi/m
请求内容:
[
{
"tnumb": null,
"request": 5,
"limitdetail": null,
"publication": null,
"merch": {
"firsn": "xxx",
"lastn": "xxx",
"nleg": "xxx",
"regn": "xxx",
"ppis": null,
"weba": "xxx",
"meri": [
{
"meri": "xxx",
"description": "ibn"
}
]
]
我必须使用基本访问身份验证方法发送用户传入标头。请帮助我如何使用php发送包含内容的标题?
如何在标题中设置用户密码?我必须在标题中发送具有基本身份验证访问权限的用户密码。应改为使用CURLOPT_USERPWD
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://pos.go.thispay.com/merchantApi/m",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS =>"[\r\n{\r\n \"tnumb\": null,\r\n \"request\": 5,\r\n \"limitdetail\": null,\r\n \"publication\": null,\r\n \"merch\": {\r\n \"firsn\": \"xxx\",\r\n \"lastn\": \"xxx\",\r\n \"nleg\": \"xxx\",\r\n \"regn\": \"xxx\",\r\n \"ppis\": null,\r\n \"weba\": \"xxx\",\r\n \"meri\": [\r\n {\r\n \"meri\": \"xxx\",\r\n \"description\": \"ibn\"\r\n }\r\n ]}}\r\n]",
CURLOPT_HTTPHEADER => array(
"Authorization: Basic dGVzdDp0ZXN0",
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;