0

当我在浏览器中输入:' https://myemail:mypassword@api.hellosign.com/v3/account '

我明白了

{"account":{"account_id":"**************","email_address":"myemail","callback_url":null,"role_code":null}} 

这似乎是一个有效的回应。

我正在尝试使用 libcurl php 库在 php 中实现这一点。我有以下内容,但是当我在 $response 变量上运行 var_dump 时得到 FALSE。关于 libcurl 设置的任何想法?我已经尝试对整个字符串进行 urlencoding 和不使用身份验证子字符串“myemail:mypassword”的 base_64 编码。提前致谢:

$final_string= 'https://myemail:mypassword@api.hellosign.com/v3/account';    

$curl = curl_init();
curl_setopt($curl, CURLOPT_USERAGENT, 'HelloSign-PHP');
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($curl, CURLOPT_URL, $final_string);
curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, self::$time_out); 

$response = curl_exec($curl);

    // Get the status code
    $http_status = curl_getinfo($curl, CURLINFO_HTTP_CODE);

    if(curl_exec($curl) === false)
        {
            echo 'Curl error: ' . curl_error($curl);
        }
        else
        {
            echo 'Operation completed without any errors';
        }

curl_close($curl);


output is : 

Curl error: SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failedProblem connecting to HelloSign.
4

1 回答 1

0

尝试以下操作:

<?php

$api_key = 'YOUR_API_KEY';
$url = 'https://api.hellosign.com/v3/account';

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERPWD, $api_key . ":"); // Normally you'd put a password after the colon, but you don't need it if you're using an API key
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
$response_json = json_decode($response, true);

print_r($response_json);

curl_close($ch);

?>

注意:您不需要使用您的 API 密钥(您可以使用您的用户名和密码,如上所述),但建议使用。您可以在此处检索您的 API 密钥:https ://www.hellosign.com/home/myAccount#api

于 2014-08-01T16:33:50.417 回答