如何在php中调用curl?

如何在php中调用curl?,php,web-services,curl,Php,Web Services,Curl,我曾尝试使用php调用下面的命令,但它给出了空白响应,所以请任何人帮助调用下面的php命令 curl -v -u [email]:[token] -X GET https://api.coolrunner.dk/v1/me 您可以使用这个curl类 有一个例子: include 'curl.class.php'; $curl = new Curl(); try { $respones = $curl->get('http://jsonplaceholder.typico

我曾尝试使用php调用下面的命令,但它给出了空白响应,所以请任何人帮助调用下面的php命令

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

您可以使用这个curl类

有一个例子:

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();
}

PHP有cURL函数,请查看文档:

@ashishmulani您能给我一份api文档吗?您可以使用这个$cURL->setBasicAuth($email,$token);在此之后,您可以调用$response=$curl->get(');$response变量是您的结果使用第三方类而不是内置的curl支持(从PHP 4.0.2开始)有什么好处?@P.J.Meisch这很简单,工作很好!php卷曲非常困难!
include 'curl.class.php';

$curl = new Curl();

$email = 'test@example.com';
$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();
}