...after hard-coding the individual url parameters and testing, I get a 403 Forbidden when printing $result. However, when I do a <form> post instead with the same url for action=, I get the expected token.json.
I've also tried: curl_setopt($rq, CURLOPT_CUSTOMREQUEST, "POST");
For cURL: Do I need to configure the headers? Or set a session attribute for $rq?
Is cURL's post inherently missing something that a <form> post satisfies?
Re: 403 Forbidden using cURL for access token request
Without seeing the response for why you're receiving the 403, you should be able to get that from the response body for the cURL request, it's hard to trouble shoot this effectively. The most common issue is that there is an encoding failure in something in the URL. This can often times happen in the redirect_uri parameter. If you've already checked these values, can you reply with the details of the 403 error you're receiving?
On another note, we do offer a fully functional PHP implementation of OAuth 2.0 with our PHP wrapper library. We highly recommend using that as it can save you a lot of time in serializing payloads, implementing OAuth and other detail pieces that can consume lots of time. Let us know if there is something missing or a reason why you decided not to use that, we'd be very interested to understand how we can make it better. You can find our PHP wrapper here: https://github.com/constantcontact/php-sdk
Dave Berard Senior Product Manager, Constant Contact
You can post a new message in the Community or find us on Twitter Mon-Fri 8am-8pm ET, Sat 10am-8pm ET, & Sun 10am-6pm ET. We've got real people waiting to help you out. Click below to start a conversation!