Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用点net或php发送restful请求_Php - Fatal编程技术网

使用点net或php发送restful请求

使用点net或php发送restful请求,php,Php,我必须向此url发送请求: https://pos.go.thispay.com/merchantApi/m 请求内容: [ { "tnumb": null, "request": 5, "limitdetail": null, "publication": null, "merch": { "firsn": "

我必须向此url发送请求:

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;