How to send a POST request using JSON format in PHP -
For Chrome, I was able to send post queries to a specific URL and use the following Restricted Client Extensions I have entered this as the header:
Accept: Application / JSN Version: 1.0.2 Authorization: Code sadkj4-sadj-as22-asdk2
As the body:
{"email": "$ email", & lt; ==== The PHP variable is given as a "password" argument: "$ password", & lt; ==== PHP variable passed as "user verified" argument: true, "notification opus": [{"notification type": "NOTIFICATION1", "enabled": true}, {"notice type": "NOTIFICATION2", "Notification type": "notification type": "notification type": "notification 3", "enabled": true}, {"notification type": "NOTIFICATION4", "enabled": true}, {"notification type": "notification 5 "," enabled ": {" notification type ":" notification 6 "," enable ": true}]," cap ":" uk "," generated password ": true}
type the content type: Application / JS
I Successfully received a response from the URL, which I have sent, but now I would like to create a PHP function which passes $ email values only in the form of email and $ password.
I have heard those people who say that I should use pride for this task, but I do not know how to do it and if I do not need it, Would not like to use Is there any other way to do this? Any help on this will be appreciated.
If possible, use cURL
.
$ json_string_data = '{ "email": "'. $ Email ',' prepare your Jason data, including e-mail / password in the 'Password' Do '.' $ Password. ' ", ...}'; $ Ch = curl_init ( 'http: // your_api_url'); Curl_setopt ($ CH, CURLOPT_CUSTOMREQUEST," POST "); Curl_setopt ($ CH, CURLOPT_POSTFIELDS, $ json_string_data); Curl_setopt ($ CH, CURLOPT_RETURNTRANSFER, true); Curl_setopt ($ ch, CURLOPT_HTTPHEADER, array ( 'content-type: application / Jason' version: 1.0.2 "," authorization codes sadkj4-sadj-as22-asdk2 ',' content-length: '. Strlen ($ Json_string_data))); $ result = Krl_akssi ($ CH);
Comments
Post a Comment