pastebin

Paste Search Dynamic
Recent pastes
postRequest
  1. <?php
  2. function postRequest($url, $data) {
  3.  
  4.     //Initiate cURL.
  5.     $ch = curl_init($url);
  6.  
  7.     //Encode the array into JSON.
  8.     $jsonDataEncoded = json_encode($data);
  9.  
  10.     //Tell cURL that we want to send a POST request.
  11.     curl_setopt($ch, CURLOPT_POST, 1);
  12.  
  13.     //Attach our encoded JSON string to the POST fields.
  14.     curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);
  15.  
  16.     //Set the content type to application/json
  17.     curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  18.         "Content-Type: application/json",
  19.         "cache-control: no-cache",
  20.         "APIKey: 123456"
  21.     ));
  22.  
  23.     //Execute the request
  24.     $result = curl_exec($ch);
  25.  
  26.  
  27.  
  28. }
  29. ?>
Parsed in 0.012 seconds