Answer the question
In order to leave comments, you need to log in
How to send data in body via curl in php?
The task is to connect the site to the api of another site.
Here's what I know.
Requests.
All requests must contain a header (Header) Authorization, in the value of which there must be a token. You can also add a language to the header, after which response descriptions will be in the appropriate language, for example:
Authorization: Token 4443a98e3389a2d90b05da7eae342e5f61ffd39c
Accept-Language: en (default=ru, en, kk)
Responses
All responses are returned in JSON format
$url = "https://testpay.post.kz/api/v0/orders/payment/";
$headers = array();
$headers[] = "Accept: application/json";
$headers[] = "Content-Type: application/json";
$headers[] = "Content-length: 0";
$headers[] = "Authorization: Token 9999079c286bfc020045a692c184246cee95bfe9";
$params = Array(
"amount"=>2000,
"back_link"=>"kazpostpay.pr/success.php",
"payment_webhook"=>"http://testpay.pruk.kz/webhook.php",
"email"=>"[email protected]");
$params = json_encode($params);
$crl = curl_init();
curl_setopt($crl, CURLOPT_HTTPHEADER,$headers);
curl_setopt($crl, CURLOPT_URL, $url);
curl_setopt($crl, CURLOPT_POST,true);
curl_setopt($crl, CURLOPT_POSTFIELDS, $params);
$rest = curl_exec($crl);
curl_close($crl);
{
"id": "b2af3619-7698-fd08-851f-24fb2403c995",
"name": "TEST SERVER",
"values": [
{
"enabled": true,
"key": "url",
"value": " https://testpay.post.kz ",
"type": "text"
},
{
"enabled": true,
"key": "token",
"value": "9999079c286bfc020045a692c184246cee95bfe9",
"type": "text "
},
{
"enabled": true,
"key": "",
"value": "",
"type": "text"
}
],
"timestamp": 1516888480700,
"_postman_variable_scope": "environment",
"_postman_exported_at": "2018-02-08T03:27:04.142Z",
"_postman_exported_using": "Postman/5.5.1"
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question