Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $list = "971292";
- $recipient = "joe@joeblowxyz.com";
- $url = 'https://api.sendgrid.com/v3/contactdb/lists/' . $list . '/recipients/' . $recipient;
- //this is the data you will send with the DELETE
- **# DO I NEED THIS?**
- $fields = array(
- 'field1' => 'field1',
- 'field2' => 'field2',
- 'field3' => 'field3'
- );
- /*ready the data in HTTP request format
- *(like the querystring in an HTTP GET, after the '?') */
- $fields_string = http_build_query($fields);
- //open connection
- $ch = curl_init();
- /*if you need to do basic authentication use these lines,
- *otherwise comment them out (like, if your authenticate to your API
- *by sending information in the $fields, above. */
- $username = 'myusername';
- $password = 'mypassword';
- curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
- /*end authentication*/
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
- curl_setopt($ch, CURLOPT_POST, count($fields));
- curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
- /*unless you have installed root CAs you can't verify the remote server's
- *certificate. Disable checking if this is suitable for your application*/
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- //perform the HTTP DELETE
- $result = curl_exec($ch);
- //close connection
- curl_close($ch);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement