-
-
Save Ginnw2/685a3172adc1427e307cdcc5d8fcda04 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$url = 'https://domain.pr/anything'; | |
$headers = ['Content-Type: application/json']; // заголовки нашего запроса | |
$post_data = [ // поля нашего запроса | |
'field1' => 'val_1', | |
'field2' => 'val_2', | |
]; | |
$data_json = json_encode($post_data); // переводим поля в формат JSON | |
$curl = curl_init(); | |
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); | |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($curl, CURLOPT_VERBOSE, 1); | |
curl_setopt($curl, CURLOPT_POSTFIELDS, $data_json); | |
curl_setopt($curl, CURLOPT_URL, $url); | |
curl_setopt($curl, CURLOPT_POST, true); | |
$result = curl_exec($curl); // результат POST запроса |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment