Suneth Kalhara Suneth Kalhara - 1 year ago 194
PHP Question

PHP execute curl Oauth

I want to send the following header using curl:

curl -H 'Authorization: OAuth oauth_signature_method="PLAINTEXT",⤦
⤥oauth_consumer_key="xxx",oauth_token="xxx",oauth_signature="xxx"' ⤦

Above command is for command line usage. Anyone know how to execute this using PHP curl?

Answer Source

The -H from curl command-line is CURLOPT_HTTPHEADER in PHP curl curl_setopt.

This should be the most basic example for what you need:

$auth = 'Authorization: YOUR_KEYS';
$url  = ',title&count=2';

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array($auth));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download