Home php PHP Send Put Request

PHP Send Put Request

Author

Date

Category

How through PHP CURL Send this request PUT .

PUT / API / Tickets / {ID}
{
 "ID": 123,
 "Title": "Help Me!",
 "Group": "Users",
 "STATE": "Open",
 "PRIORITY": "3 HIGH",
 "Article": {
  "SUBJECT": "Some Subject of Update",
  "BODY": "Some Message of Update"
 },
 ...
}

Answer 1, Authority 100%

I advise you in more detail to study examples of requests CURL
More information here
Example with comments (it is assumed that the type of data transfer JSON):

$ url = 'https://site.ru'; // Site where you send
$ id = '123'; // user ID to change
// Associated itself
$ Arraytosend = '{"id": 123,
  "Title": "Help Me!",
  "Group": "Users",
  "STATE": "Open",
  "PRIORITY": "3 HIGH",
  "Article":
  {
    "SUBJECT": "Some Subject of Update",
    "BODY": "Some Message of Update"
  }
} ';
$ CURL = CURL_INIT ();
CURL_SETOPT_ARRAY ($ CURL, Array (
  Curlopt_url = & gt; $ url. "/ API / Tickets /". $ id
  Curlopt_returntransfer = & gt; True
  Curlopt_encoding = & gt; "",
  Curlopt_maxredirs = & gt; ten,
  Curlopt_timeout = & gt; thirty,
  Curlopt_http_version = & gt; Curl_http_version_1_1,
  Curlopt_customrequest = & gt; "PUT",
  Curlopt_postfields = & gt; "$ Arraytosend",
  Curlopt_httpheader = & gt; Array (
    "CONTENT-TYPE: Application / JSON",
    "Cache-Control: NO-Cache"
  ),
));
$ Response = CURL_EXEC ($ CURL);
$ ERR = CURL_ERROR ($ CURL);
CURL_CLOSE ($ CURL);
if ($ ERR) {
  Echo "Curl Error #:" $ ERR;
} else {
  Echo $ Response;
}

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions