0

i must send request to this url:

https://pos.go.thispay.com/merchantApi/m

content of request:

[
{
    "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"
            }
        ]

]

i must be send user pass in header with basic access authentication method. please help me how i can send header with content with php?

1 Answers1

0
<?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;

Ben Huang
  • 11
  • 2