Hi, I'm not a PHP developer by trade (ColdFusion actually) but my client needs this done in PHP. Here's what I've done so far:
1. I added the oAuth library from the google code website.
2. I have an index.html page (which has an e-mail address form for the user to enter their e-mail address form.
3. I have the oAuth code from David J's post in this forum on using oAuth to authenticate the site.
4. When I tried the first time to submit an e-mail address, I got redirected to the constant contact authentication page (which is what I expected). I entered my constant contact usernamd and password and submitted. Afterwards, I got a page that simply said "an error occurred, please contact us.".
Does anyone have an implementation already done of PHP and oAuth? I need to get this working today and without any error information at all on the screen I can't even begin to figure it out. I'm going crazy!
Thanks,
Dave
Hi Dave,
I apologize for the delayed response over the weekend, but I am more than happy to assist you with this. Without seeing the PHP code that you have, it makes it difficult for me to begin troubleshooting what may be happening, but if the user is getting redirected to Constant Contact to authenticate, you must be pretty close to having the successfully working.
With that being said, I just saw the email you sent to our Webservices Team. I am taking a look at that now and will respond as soon as I have anymore information.
David J
Hi David,
Any luck on this? My client is getting antsy. :) I'm stumped.
682-222-7083
Dave
Dave J is out of the office today, but I did see that he sent you a response yesterday to the email you sent in. Below is the response he sent over:
I think the issue here is that there are a few pieces of conflicting information in your actual request to create a contact. Fortunately, since this is the very last step in your process, a minimal amount of changes need to be made.
1. This line is setting up a request for a 'GET' (as seen by the 3rd argument passed to the from_consumer_and_token function:
$api_request = OAuthRequest::from_consumer_and_token($oauth_consumer, $authorization_token, 'GET', $webServiceUrl);
2. You are then passing in XML that would be used to create a new contact, and using the URL to create a new contact (https://api.constantcontact.com/ws/customers/{username}/contacts).
3. Finally, it looks as though you are using curl options to perform a 'PUT' (update):
curl_setopt($session, CURLOPT_PUT, 1);
curl_setopt($session, CURLOPT_CUSTOMREQUEST, "PUT");
In order to get this to work, you would want to use:
1) $api_request = OAuthRequest::from_consumer_and_token($oauth_consumer, $authorization_token, 'POST', $webServiceUrl);
2. Use the following curl_setopt: curl_setopt($session, CURLOPT_CUSTOMREQUEST, "POST");
3. Add the following curl option to specify the the content-type/content-length:
curl_setopt($session, CURLOPT_HTTPHEADER, Array("Content-Type:application/atom+xml", 'Content-Length: ' . strlen($parameter)));
Alternatively, I am in the final stages of testing a full PHP Wrapper library that uses oauth authentication. While it is still in beta and always subject to change before we release it, this would save you a lot of the processing you are doing, and having these actions like "createContact" already built in as functions. If you're interested in trying this out, please let me know and I'd be happy to send that over.
If you have any questions or concerns regarding this, please let me know and I will be happy to help. Thanks.
Thanks, for some reason I did NOT get that e-mail. Please pass my thanks along to David and also yes, I'm interested in beta testing the wrapper for oAuth.
Thanks!
Dave
Okay, I made the changes you recommended. I still get the same error:
HTTP Status 401 - Invalid signature for signature method HMAC-SHA1
I appreciate your help!
Dave
Sorry for the confusion earlier. I will try sending an email outside of our ticketing system to see is that helps the email arrive in your inbox. There were a couple of other hiccup in the XML that were causing an issue with your contact being created, but this should prevent that.
If you have any questions please respond to this post or to the email that I'll be sending you and I'll be happy to help. Thanks.
David J
The holidays have come and gone. For many seasonal businesses, this means the rush of shoppers has decreased as well. Instead of turning off the lights and waiting for spring, make your email marketi...
See Article