Advertisement
Guest User

Untitled

a guest
Jan 25th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. <?php
  2.  
  3. $list = "971292";
  4. $recipient = "joe@joeblowxyz.com";
  5. $url = 'https://api.sendgrid.com/v3/contactdb/lists/' . $list . '/recipients/' . $recipient;
  6.  
  7. //this is the data you will send with the DELETE
  8. **# DO I NEED THIS?**
  9. $fields = array(
  10. 'field1' => 'field1',
  11. 'field2' => 'field2',
  12. 'field3' => 'field3'
  13. );
  14.  
  15. /*ready the data in HTTP request format
  16. *(like the querystring in an HTTP GET, after the '?') */
  17. $fields_string = http_build_query($fields);
  18.  
  19. //open connection
  20. $ch = curl_init();
  21.  
  22. /*if you need to do basic authentication use these lines,
  23. *otherwise comment them out (like, if your authenticate to your API
  24. *by sending information in the $fields, above. */
  25. $username = 'myusername';
  26. $password = 'mypassword';
  27.  
  28. curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
  29. /*end authentication*/
  30.  
  31. curl_setopt($ch, CURLOPT_URL, $url);
  32. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  33. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
  34. curl_setopt($ch, CURLOPT_POST, count($fields));
  35. curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
  36.  
  37. /*unless you have installed root CAs you can't verify the remote server's
  38. *certificate. Disable checking if this is suitable for your application*/
  39. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  40.  
  41. //perform the HTTP DELETE
  42. $result = curl_exec($ch);
  43.  
  44. //close connection
  45. curl_close($ch);
  46. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement