Advertisement
ardann

Untitled

Apr 27th, 2018
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. <?php
  2. /*
  3. $url = 'https://api.secreto.site/sendmsg';
  4. $data = array (
  5. 'id' => '2878659',
  6. 'message' => 'curl post PHP',
  7. );
  8. $ch=curl_init($url);
  9. $data_string = urlencode(json_encode($data));
  10. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
  11. curl_setopt($ch, CURLOPT_POSTFIELDS, array("customer"=>$data_string));
  12.  
  13.  
  14. $result = curl_exec($ch);
  15. curl_close($ch);
  16.  
  17. echo $result;*/
  18.  
  19.  
  20. $url = 'https://api.secreto.site/sendmsg';
  21.  
  22. //create a new cURL resource
  23. $ch = curl_init($url);
  24. $msg = "posting pesan dengan curl";
  25. //setup request to send json via POST
  26. $data = array (
  27. 'id' => '2878659',
  28. 'message' => 'curl post PHP',
  29. );
  30. $data_string = json_encode(array("spam" => $data));
  31.  
  32. //attach encoded JSON string to the POST fields
  33. curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
  34.  
  35. //set the content type to application/json
  36. curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  37. 'Content-Type:application/json',
  38. 'origin: https://secreto.site',
  39. 'accept-encoding: gzip, deflate, br',
  40. 'accept-language: en-US,en;q=0.9',
  41. 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.62 Safari/537.36',
  42.  
  43. ));
  44.  
  45. //return response instead of outputting
  46. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  47.  
  48. //execute the POST request
  49. $result = curl_exec($ch);
  50.  
  51. //close cURL resource
  52. curl_close($ch);
  53.  
  54.  
  55. //Output response
  56. echo "\n$result\n";
  57.  
  58.  
  59. //get response
  60. $data = json_decode(file_get_contents('php://input'), true);
  61.  
  62. //output response
  63. echo $data;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement