SendGrid -- How to delete a single Marketing Campaign recipient with API and PHP - sendgrid

Will someone help me with the PHP code to authenticate my Sendgrid account connection and then delete a Marketing Campaign recipient via API?
From the help documentation, this appears to be the command line -- DELETE https://api.sendgrid.com/v3/contactdb/lists/{list_id}/recipients/{recipient_id} HTTP/1.1 -- but I can't figure out what to do with it, since it isn't regular PHP code. The only sample code I found pertained to Legacy Newletters (which I got to work) and not contacts used by Marketing Campaigns.

What are you using to interact with the API? cURL? You just need to make an HTTP DELETE request to the url https://api.sendgrid.com/v3/contactdb/lists/{list_id}/recipients/{recipient_id}, replacing {list_id} and {recipient_id} with the IDs of the list and the recipient.
Here's an example of a function that will make a delete request for you with cURL: https://stackoverflow.com/a/17935536/401096

Related

How to send transactions to the sandbox paypal using paypal API?

I am trying to create some payments with transactions on my sandbox API. I followed the doc here https://developer.paypal.com/docs/api/payments/v1/#payment_create and inserted the request body in postman but I get a 404 error. I am not using the deprecated endpoint. Can someone help?
v1/payments is a deprecated API.
Use the current v2/checkout/orders API, documented here.
Impossible to advise on the reason for the 404 without seeing a log of your request and response, but make sure you are successfully obtaining an access token first. There is a postman collection at https://www.postman.com/paypal/

Twilio SendGrid Global Email Statistics Access Forbidden

I have setup a SendGrid API key with full access and was trying to get global email statistics using the online tool that goes with the documentation ... but the response I get says access forbidden. I'm not sure what to do because my API key has full access. Can anyone with experience using the Twilio SendGrid API offer advice?
Twilio developer evangelist here.
I think the issue here is that you have the default on-behalf-of text still in the form. It's not a regular placeholder text, but actual text.
Delete the text that start "The subuser's username..." and try again. It should work.

What's the REST way to verify an email?

When a user register to my web application I send an email to verify his inbox.
In the email there are a link to a resource like this:
GET /verify/{token}
Since the resource is being updated behind the scenes, doesn't it break the RESTful approach?
How can I do it in a RESTful manner?
What you are talking about is not REST. REST is for machine to machine communication and not for human to machine communication. You can develop a 1st party REST client, which sends the activation to the REST service.
You can use your verification URI in the browser to access the REST client:
# user follows a hyperlink in the browser manually
GET example.com/client/v1/verify/{token}
# asking the client to verify the token
and after that the REST client will get the hyperlink for verification from the REST service and send the POST to the service in the background.
# the REST client follows the hyperlinks given by the service automatically
# the REST client can run either on the HTTP client or server side
GET example.com/api/v1
# getting the starting page of the REST service
# getting the hyperlink for verification
POST example.com/api/v1/verification {token}
# following the verification hyperlink
If you have a server side 1st party REST client, then the HTTP requests to the REST service will run completely on the server and you won't see anything about it in the browser. If you have a client side REST client, then you can send the POST in the browser with AJAX CORS or you can try to POST directly with a HTML form (not recommended). Anyways the activation should be a POST or a PUT.
It depends on what are you trying to do.
Does it fire an email after validating the user for example? If so, it is not an idempotent method and you should use POST.
Example:
POST /users/{id}/verify/{token}
If the method doesn't have any consequence besides the update, I think you should use PUT.
Aren't you overthinking REST? With e-mail verification you want the user to be able to simply click the link from whatever mail user agent he is using, so you'll end up with a simple GET on the server (presented as a hyperlink to the user) with the token either in the path or as part of the query string:
GET http://example.com/verify-email/TOKEN
GET http://example.com/verify-email?token=TOKEN
Either is fine for this use case. It is not really a resource you are getting or creating; just a trigger for some process on the backend.
Why do you think this would run afoul of good design?

Receiving INTERNAL_SERVICE_ERROR REST API

Using REST API, sandbox and attempting to get bearer token. Receiving the following error
{"name":"INTERNAL_SERVICE_ERROR","information_link":"https://api.sandbox.paypal.com/docs/api/#INTERNAL_SERVICE_ERROR","debug_id":"5a235c510522b"}
How can I find out what the debug id means?
The 'debug_id' is an internal identifier we can use to pull up the request within PayPal.
You may see our classic API calls refer to this as the 'correlationID'.
Unfortunately I'm not finding anything in our system for this debug_id. Can you log a ticket (www.paypal.com/mts) or email me (address in profile) with details of the call, including your full HTTP request (minus credentials) and the resources you tried to access, as well as the full HTTP response?
I suggest we close this answer as it's not strictly programming-related, but I can continue working on this via mail / ticket with you.
By the way; if you're using the 4111111111111111 credit card: this card number is currently inoperable in the Sandbox environment and may throw 'internal service error' type responses as well. You can use any other card number instead.

Error code 100 (Can only call this method on valid test users for your app)

getting the error {"error":{"message":"(#100) Can only call this method on valid test users for your app","type":"OAuthException"}} whenever trying to write to any facebook end point. Reading (GET) works fine, writing (POST) fails. Does anybody know how to resolve this?
I have also opened a ticket on FB dev site:
http://developers.facebook.com/bugs/184198634991192?browse=search_4e93328871c8a3231774584
The problem does not occur is I would shoot the POST request from my browser as if I am the user.
The problem does occurs only when sending from our servers on behalf of the user from one of our dev machines which have other subdomain names instead of www (such as dev1.blablabla.com & dev2.blablabla.com, while the app is registered to www.blablabla.com).
So the question is, does facebook attempt to do a reverse DNS lookup on all write requests to verify the source?
I believe your requirement is to get the user details of the owner of Facebook access token (normally the currently logged in user)
For that you have to issue a GET request and not a POST request.
The reason why it works when fired from the browser is that when you submit a query through the address bar it is send as a GET request, and when sent from your server it is send as POST and fails producing the error message mentioned in your post.
Facebook doesn't do a reverse DNS lookup on your write request and not need to configure anything in your server related to it.
Hope the answer is clear enough for you.