ashish mulani
ashish mulani

Reputation: 197

How to call curl in php?

I have try to call below command in using php but its give blank response so please anyone help to call below command in php.

curl -v -u [email]:[token] -X GET https://api.coolrunner.dk/v1/me

Upvotes: 3

Views: 603

Answers (2)

Amir Mohsen
Amir Mohsen

Reputation: 851

You can use this curl class

There is a sample :

include 'curl.class.php';

$curl = new Curl();

try {
    $respones = $curl->get('http://jsonplaceholder.typicode.com/posts/1');
    var_dump($respones);
    $result = json_decode($respones);
    echo "<br />Title : ".$result->title;
}catch (Exception $e){
    echo $e->getMessage();
    echo $curl->getError();
}

I think this is a sample for your request :

include 'curl.class.php';

$curl = new Curl();

$email = '[email protected]';
$token = 'kaiDklasdfSDFv6adsfvjhsadr';
try {
    $curl->setBasicAuth($email,$token);
    $respones = $curl->get('https://api.coolrunner.dk/v1/me');
    var_dump($respones);
}catch (Exception $e){
    echo $e->getMessage();
    echo $curl->getError();
}

Upvotes: 2

Abacus
Abacus

Reputation: 19421

PHP has cURL functions, check the documentation: PHP: cURL Functions

Upvotes: 0

Related Questions