Jan Aranas Jan Aranas - 7 days ago 5
JSON Question

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

Answer

In your case data for login is: user@company.com:test. And you can use curl in ssh like follows:

curl -u user@company.com:test https://security.voluum.com/login

PHP

You can also execute this in PHP as follows:

$user='user@company.com';
$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 == user@company.com: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

Comments