Location: Resolved Issues

Discussion: Userservice/Login errors with INVALID_DEVELOPER_KEYReported This is a featured thread

Showing 3 posts

focusnfly
Userservice/Login errors with INVALID_DEVELOPER_KEY
Jul 16 2008, 8:16 PM EDT | Post edited: Jul 16 2008, 8:16 PM EDT
Following is the php code that I wrote. I used the developer key provided in wetpaint website for sandbox-trial namespace.

<?php
// Get User Login Token from wetpaint injected
$url = "http://togo.wetpaint.com/UserService/login.do";
$wetpaint_developer_key = "507ace0d168024cbcb53a9add0e6fe4e9796012e6b420cfafabac6a4357824ef";
$wetpaint_developer_secret = "25da5302b335b2d5f3d65eedb8a10b76190da51f255cc1e708e06c3c7dbd6853";
$wetpaint_developer_content_namespace = "sandbox-trial";
$ts = time();
$user_login = "focusnfly";
$sig = sha1($wetpaint_developer_key.$user_login.$ts.$wetpaint_developer_secret);
$params = "output=api"
. "&key=" . $wetpaint_developer_key
. "&ns=" . $wetpaint_developer_content_namespace
. "&cred.ts=" . $ts
. "&cred.sig=" . $sig
. "&user.userId=" . $user_login
. "&user.email=tom@focusnfly.com"
. "&user.emailOptIn=false"
. "&user.role=registered"
. "&user.displayName=Tom";

$ch = curl_init(); // initialize curl handle
curl_setopt($ch, CURLOPT_URL,$url); // set url to post to
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
curl_setopt($ch, CURLOPT_TIMEOUT, 3); // times out after 4s
curl_setopt( $ch, CURLOPT_POST, true ); // set POST method

curl_setopt($ch, CURLOPT_POSTFIELDS, $params); // add POST fields
$result = curl_exec($ch); // run the whole process
curl_close($ch);
echo $result;
?>
Do you find this valuable?    
Keyword tags: INVALID_DEVELOPER_KEY
devin_wetpaint
devin_wetpaint
1. RE: Userservice/Login errors with INVALID_DEVELOPER_KEY
Jul 17 2008, 12:33 PM EDT | Post edited: Jul 17 2008, 12:33 PM EDT
Hi,

Ahh, the algorithm for generating the signature has changed since that example was written. I'll update the PHP example now.

---cut from http://www.wetpaintinjected.com/page/UserService.login
cred.sig
Developer credential signature. This is calculated as the HMAC-SHA-1 hash of the developer key (the key parameter), the user ID (the user.userId parameter, described below), and the current timestamp (the cred.ts parameter). The key used by the HMAC-SHA-1 algorithm should be the developer secret. For example, in PHP: $sig = hash_hmac( "sha1", $developer_key . $user_id . time(), $developer_secret, FALSE ); Example data is available.

Everything else should be gravy. Let me know if you have any other problems.

Thanks!
- DC
1  out of 1 found this valuable. Do you?    

focusnfly
2. RE: Userservice/Login errors with INVALID_DEVELOPER_KEY
Jul 20 2008, 1:07 AM EDT | Post edited: Jul 20 2008, 1:07 AM EDT
Thanks a lot DC! Your suggestion worked. PHP Version that I currently have is 4.3.9. I could not find hash_hmac function. PECL extensions for PHP comes with hash_hmac function. So, I got the user login working correctly now. Do you find this valuable?    

Related Content

  (what's this?Related ContentThanks to keyword tags, links to related pages and threads are added to the bottom of your pages. Up to 15 links are shown, determined by matching tags and by how recently the content was updated; keeping the most current at the top. Share your feedback on Wetpaint Central.)