How do I translate this to php curl?


#1

Using the oAuth tool in my application, I get this cURL command to execute a status update. I’m not sure how to translate this into a PHP cURL command. Can anyone give me a pointer?

curl --request 'POST' 'https://api.twitter.com/1/statuses/update.json' --data 'status=Maybe+he%27ll+finally+find+his+keys.+%23peterfalk' --header 'Authorization: OAuth oauth_consumer_key="***", oauth_nonce="97fad626790e8e5988d4a06cfd47fa74", oauth_signature="***", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1364161424", oauth_token="***", oauth_version="1.0"' --verbose

Is this close?

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.twitter.com/1/statuses/update.json');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('data: status=Maybe+he%27ll+finally+find+his+keys.+%23peterfalk', 'Authorization: OAuth oauth_consumer_key="***", oauth_nonce="97fad626790e8e5988d4a06cfd47fa74", oauth_signature="***", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1364161424", oauth_token="***", oauth_version="1.0"'));
$data = curl_exec($ch);
curl_close($ch);
return $data;

#2

You won’t be able to do things quite like that – the curl commands the OAuth tool generate will only be valid for a few minutes. You need to implement the entire OAuth signing process.


#3

You can use this one https://dev.twitter.com/discussions/14460 to translate in php