Jan Aranas
Jan Aranas

Reputation: 67

Curl to php or json

i need help i've been trying to run this

curl -H "Authorization: Basic dXNlckBjb21wYW55LmNvbTp0ZXN0" https://security.voluum.com/login

but quite stuck, also is it possible to create this in php or in json? i need data to create something. also i tried replacing dXNlckBjb21wYW55LmNvbTp0ZXN0 with my own 64bit username:pass but still not working can someone explain this i really dont know what to do

Upvotes: 1

Views: 339

Answers (1)

Karol Gasienica
Karol Gasienica

Reputation: 2904

In your case data for login is: [email protected]:test. And you can use curl in ssh like follows:

curl -u [email protected]:test https://security.voluum.com/login

PHP

You can also execute this in PHP as follows:

$user='[email protected]';
$pass='test';
$url='https://security.voluum.com/login';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_USERPWD, "$user:$pass");
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);   //get status code
$result=curl_exec($ch);
curl_close($ch);
echo "Status code: $status_code \n";
print_r($result);

More informations

Base64

dXNlckBjb21wYW55LmNvbTp0ZXN0 == [email protected]:test you can decode/encode it by yourself here

Curl

More about -u you can read here. And curl manual is available here

PHP

PHP:Curl Manual

Upvotes: 1

Related Questions