Vid Vid - 6 months ago 142
PHP Question

docusign php api login example is not working

I am not succeeding to login into docusign with PHP API. I am getting error
with timeout. But most interestingly I am able to login via REST client
on address with header which is below


https://demo.docusign.net/restapi/v2/login_information



X-DocuSign-Authentication: <DocuSignCredentials><Username>zzzzzzz@yyyy.com</Username><Password>somepasss</Password><IntegratorKey>TEST-xxxxxxxxxxxxxxxxxxxx</IntegratorKey></DocuSignCredentials>Accept: application/json Content-Type: application/json




Does any one have any idea of this error cause? (php configuration, modules extensions? Firewall? geo location restrictions? )

Fatal error: Uncaught exception 'DocuSign\eSign\ApiException' with message 'API call to https://demo.docusign.net/restapi/v2/login_information timed out: a:26:{s:3:"url";s:54:"https://demo.docusign.net/restapi/v2/login_information";s:12:"content_type";N;s:9:"http_code";i:0;s:11:"header_size";i:0;s:12:"request_size";i:0;s:8:"filetime";i:-1;s:17:"ssl_verify_result";i:1;s:14:"redirect_count";i:0;s:10:"total_time";d:0.842999999999999971578290569595992565155029296875;s:15:"namelookup_time";d:0.51500000000000001332267629550187848508358001708984375;s:12:"connect_time";d:0.6870000000000000550670620214077644050121307373046875;s:16:"pretransfer_time";d:0;s:11:"size_upload";d:0;s:13:"size_download";d:0;s:14:"speed_download";d:0;s:12:"speed_upload";d:0;s:23:"download_content_length";d:-1;s:21:"upload_content_length";d:-1;s:18:"starttransfer_time";d:0;s:13:"redirect_time";d:0;s:12:"redirect_url";s:0:"";s:10:"primary_ip";s:14:"162.248.186.25";s:8:"certinfo";a:0:{}s:12:"primary_port";i:443;s:8:"local_ip";s:13:"192.168.1.126";s:10:"local in C:\xampp\htdocs\localbits\ds\docusign\src\ApiClient.php on line 233
( ! ) DocuSign\eSign\ApiException: API call to https://demo.docusign.net/restapi/v2/login_information timed out: a:26:{s:3:"url";s:54:"https://demo.docusign.net/restapi/v2/login_information";s:12:"content_type";N;s:9:"http_code";i:0;s:11:"header_size";i:0;s:12:"request_size";i:0;s:8:"filetime";i:-1;s:17:"ssl_verify_result";i:1;s:14:"redirect_count";i:0;s:10:"total_time";d:0.842999999999999971578290569595992565155029296875;s:15:"namelookup_time";d:0.51500000000000001332267629550187848508358001708984375;s:12:"connect_time";d:0.6870000000000000550670620214077644050121307373046875;s:16:"pretransfer_time";d:0;s:11:"size_upload";d:0;s:13:"size_download";d:0;s:14:"speed_download";d:0;s:12:"speed_upload";d:0;s:23:"download_content_length";d:-1;s:21:"upload_content_length";d:-1;s:18:"starttransfer_time";d:0;s:13:"redirect_time";d:0;s:12:"redirect_url";s:0:"";s:10:"primary_ip";s:14:"162.248.186.25";s:8:"certinfo";a:0:{}s:12:"primary_port";i:443;s:8:"local_ip";s:13:"192.168.1.126";s:10:"local_port";i:38524;} in C:\xampp\htdocs\localbits\ds\docusign\src\ApiClient.php on line 233


and the php code is below:

<?php
require_once('./docusign/autoload.php');

class DocuSignSample
{
public function login()
{
$username = "__some email__";
$password = "__some password___";
$integrator_key = "TEST-xxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$host = "https://demo.docusign.net/restapi";

$config = new DocuSign\eSign\Configuration();
$config->setHost($host);
$config->addDefaultHeader("X-DocuSign-Authentication", "{\"Username\":\"" . $username . "\",\"Password\":\"" . $password . "\",\"IntegratorKey\":\"" . $integrator_key . "\"}");

$apiClient = new DocuSign\eSign\ApiClient($config);

$authenticationApi = new DocuSign\eSign\Api\AuthenticationApi($apiClient);

$options = new \DocuSign\eSign\Api\AuthenticationApi\LoginOptions();

$loginInformation = $authenticationApi->login($options);
if (isset($loginInformation) && count($loginInformation) > 0) {
$loginAccount = $loginInformation->getLoginAccounts()[0];
if (isset($loginInformation)) {
$accountId = $loginAccount->getAccountId();
if (!empty($accountId)) {
echo $accountId;
}
}
}
}
}

$dss = new DocuSignSample();

$dss->login();

?>

Vid Vid
Answer

I was experiencing difficulties to use API up until I found that it is needed to have a signed ssl with http server and php or there is also insecure solution which is simply to disable ssl checking in curl (curl was cause of this inconvenience):

 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);  
Comments