I`m trying to make a simple search request, but always 401 error Unauthorized.
All requests via Two-legged OAuth.
Nothing special - just dummy request without any parameters. Playground returb
$url = "http://rest.immobilienscout24.de/restapi/api/search/v1.0/search/"; # no parameters here - just for test
$timestamp = time();
$nonce = base64_encode(uniqid()); # just unique
$base = 'GET&'.rawurlencode($url).'&'
.rawurlencode("&oauth_consumer_key=".rawurlencode(CONSUMER_KEY)
.'&oauth_nonce='.rawurlencode($nonce)
.'&oauth_signature_method='.rawurlencode('HMAC-SHA1')
.'&oauth_timestamp='.rawurlencode($timestamp)
.'&oauth_version='.rawurlencode('1.0')
);
$key = rawurlencode(CONSUMER_SECRET)."&";
$sig = base64_encode(hash_hmac("sha1", $base, $key, true));
$headers =[
'Authorization: '.rawurlencode('OAuth oauth_nonce="'.$nonce.'",oauth_consumer_key="'.CONSUMER_KEY.'",oauth_signature_method="HMAC-SHA1",oauth_timestamp="'.$timestamp.'",oauth_version="1.0",oauth_signature="'.$sig.'"')
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$a = curl_exec($ch);
CONSUMER_KEY is Immostat24_v2Key
Where I am wrong?