note 113029 deleted from function.curl-setopt by cmb
| From: | cmb@php.net | Date: | Sun, 17 Nov 2019 08:55:54 +0000 |
| Subject: | note 113029 deleted from function.curl-setopt by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-213097@lists.php.net to get a copy of this message | ||
Note Submitter: mfuhrman at enetarch dot net
----
Here is an example of sending JSON data as via POST.
index.php
------
$data = array
(
"command" => "isInstalled",
"params" => Array
(
"1" => "3",
"2" => "4",
)
);
$data_string = "json=" . json_encode($data) . "&";
$ch = curl_init("http://localhose/parrot.php");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
$results = curl_exec($ch);
print ($results);
?>
=====
parrot.php
------
<?
print_r ($_REQUEST);
?>