所以我正在尝试使用 REST 和 cURL 和 PHP(Codeigniter)从我们的自定义界面登录到我们的 DocuSign 开发帐户。这是我到目前为止的代码:
<?php
$integratorKey = '****-********-****-****-****-************';
$username = '';
$password = '';
$header = "<DocuSignCredentials><Username>" . $username . "</Username><Password>" . $password . "</Password><IntegratorKey>" . $integratorKey . "</IntegratorKey></DocuSignCredentials>";
$url = "https://demo.docusign.net/restapi/v2/login_information";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, array("Content-Type: application/xml"));
curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-DocuSign-Authentication: $header"));
curl_setopt($ch, CURLOPT_UNRESTRICTED_AUTH, 1);
$output = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ( $status != 200 ) {
echo "error calling webservice, status is:" . $status;
exit(-1);
}
$response = json_decode($output, true);
$accountId = $response["loginAccounts"][0]["accountId"];
$baseUrl = $response["loginAccounts"][0]["baseUrl"];
curl_close($ch);
?>
<div id="container">
<h1>Welcome</h1>
<div id="login_form">
<h1>Login</h1>
<?php
echo form_open('login/hello');
echo form_input($username, 'Username');
echo form_password($password, 'Password');
echo form_submit('submit', 'Submit');
?>
</div>
</div>
我得到的错误是 400。我意识到这可能是因为它在用户输入用户名和密码之前发送了标题。我想我不确定如何让它“等待”,直到在发送标头请求之前按下提交按钮。这是我第一次尝试 REST 和 cURL。任何帮助将不胜感激。