This was supposed to be post asking for help about oauth_signature is invalid error, but while writing it, i managed to solve the problem, so i thought to share how to do it in php.
"RAW" method
<?php$now = time();$app_secret = "..."; //from 'view my application keys' page$token_secret = "..."; //shown after installing application: access_token;token_secret$access_token = "..."; //shown after installing application: access_token;token_secret$versionString = "?v=1";$accountId = "P...";$baseAddr = "https://dev.liveperson.net/api/account/"; //this is address returned in header of response to request to https://api.liveperson.net/api/account/[account]?v=1// for example for live account it will be https://server.iad.liveperson.net/api/account/$appKey = "..."; //from 'view my application keys' page$oauth_params = array('oauth_consumer_key' => $appKey,'oauth_nonce' => "c1c04ec4-3125-44cf-9c39-cccb9343541b",'oauth_signature_method' => "HMAC-SHA1",'oauth_timestamp' => $now,'oauth_token' => $access_token,'oauth_version' => "1.0",'v' => "1");$base_string = "GET&".urlencode($baseAddr.$accountId)."&".urlencode(http_build_query($oauth_params));$sig = urlencode(base64_encode(hash_hmac('SHA1', $base_string, $app_secret."&".$token_secret, true)));$headersAgent = array('Accept: application/xml','Authorization: OAuth oauth_signature="'.$sig.'",oauth_version="1.0",oauth_nonce="c1c04ec4-3125-44cf-9c39-cccb9343541b", oauth_consumer_key="'.$appKey.'",oauth_signature_method="HMAC-SHA1",oauth_token="'.$access_token.'",oauth_timestamp="'.$now.'"','Content-Type: application/xml');$strUrl = $baseAddr.$accountId.$versionString;var_dump($headersAgent);$objCurl = curl_init();curl_setopt($objCurl, CURLOPT_URL, $strUrl);curl_setopt($objCurl, CURLOPT_HEADER, 1);curl_setopt($objCurl, CURLOPT_HTTPHEADER, $headersAgent);curl_setopt($objCurl, CURLOPT_RETURNTRANSFER, 1);curl_setopt($objCurl, CURLOPT_SSL_VERIFYHOST, 0);curl_setopt($objCurl, CURLOPT_SSL_VERIFYPEER, 0);$objResult = curl_exec($objCurl);var_dump($objResult);?>
Method using pecl Oauth library:
<?php try { $now = time(); $app_secret = "..."; $token_secret = "..."; $access_token = "..."; $versionString = "?v=1"; $accountId = "P..."; $baseAddr = "https://dev.liveperson.net/api/account/"; $appKey = "..."; $oauth = new OAuth($appKey,$app_secret,OAUTH_SIG_METHOD_HMACSHA1,OAUTH_AUTH_TYPE_URI); $oauth->setToken($access_token,$token_secret); $oauth->fetch("https://dev.liveperson.net/api/account/P42881958?v=1"); var_dump($oauth->getLastResponse()); } catch(OAuthException $E) { print_r($E); } ?>
Two notes here: no need to use $oauth->setTimestamp and no need to use $oauth->setNonce, which would suggest that 'nonce' parameter can be truly random for accessing LivePerson signed APIs
Hope this helps anyone
Cheers,
Andrew