Help get this topic noticed by sharing it on Twitter, Facebook, or email.

Problem with Request token

Hi

When i request the requesttoken through curl it fetches the whole sign up page.How can i get the response or buy pass the signup.

here is my code.

$consumer = consumer-key;
$secret = secret-key;
$callback = callback-url;
$sign_method = 'HMAC-SHA1';
$version = '1.0';

/****************UrlEncode***************/
function urlencodeRFC3986($string)
{
return str_replace('%7E', '~', rawurlencode($string));
}

/*****************Time stamps & Random String **************/
$mt = microtime();
$rand = mt_rand();
$nonce = md5($mt.$rand);
$time = time();

/******************Request Url*********************/
$url = 'http://api.cohuman.com/api/token/requ...;
$path = '/api/token/request';

/************Authetication Header******************/
$post = array(

'oauth_consumer_key' => $consumer,
'oauth_nonce' => $nonce,
'oauth_signature_method' => $sign_method,
'oauth_timestamp' => $time,
'oauth_version' => $version
);

$post_string = '';

foreach($post as $key => $value)
{
$post_string .= $key.'='.($value).'&';
}
$post_string = rtrim($post_string, '&');

$key_parts = array($secret);

$key_parts = urlencodeRFC3986($secret);
//$key = implode('&', $key_parts);
$key = $key_parts.'&';

/***********************Build Base String************************/
$base_string = 'POST&'.urlencodeRFC3986($url).'?'.urlencodeRFC3986($post_string);

/*****************************Generate Signature************************/
$signature = base64_encode(hash_hmac('sha1', $base_string, $key, true));

/*******************Authentication header*******************/

$post = array(
'realm'=>"http://api.cohuman.com/",
'oauth_version' => $version,
'oauth_nonce' => $nonce,
'oauth_timestamp' => $time,
'oauth_consumer_key' => $consumer,
'oauth_callback' => $callback,
'oauth_signature_method' => $sign_method,
'oauth_signature' => $signature
);

$header_string = '';

/*************Header String*****************/
foreach($post as $key => $value)
{
$header_string .= $key.'="'.urlencodeRFC3986($value).'", ';
}

$header_string = trim($header_string);
$header_string = rtrim($header_string, ',');

/*****************HTTP POST HEADER********************/
$header[] = 'POST '.$path.' HTTP/1.1';
$header[] = 'Host: www.cohuman.com';
$header[] = 'Accept: */*';
$header[] = 'Content-Type: application/x-www-form-urlencoded';
$header[] = 'Authorization: OAuth '.$header_string;

/**********************Execute Curl*************************/
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_URL, 'http://api.cohuman.com/api/token/requ...;
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$code = curl_getinfo($ch,CURLINFO_HTTP_CODE);

$result = curl_exec($ch);
curl_close($ch);
print_r($result);
die();

Thanks
Nick
1 person has
this problem
+1
Reply