【问题标题】:Handshake error in PHP call to SurveyMonkey API V3对 SurveyMonkey API V3 的 PHP 调用中的握手错误
【发布时间】:2017-07-14 18:56:04
【问题描述】:

我是 REST 新手,我的任务是使用 V3 API 检索 SurveyMonkey 调查数据。我正在使用 PHP。我的代码如下:

$fields = array(
'title'=>'New Admission Survey',
'object_ids' => array($surveyID));

$fieldsString = json_encode($fields);

$curl = curl_init();
$requestHeaders = array(
"Authorization" => 'bearer abc123',
"Content-Type" => 'application/json',
'Content-Length: ' . strlen($fieldsString));

$baseUrl = 'https://api.surveymonkey.net/v3';
$endpoint = '/surveys/';

curl_setopt($curl, CURLOPT_URL, $baseUrl . $endpoint);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $requestHeaders);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($curl, CURLOPT_POSTFIELDS, $fieldsString);
$curl_response = curl_exec($curl);

if($curl_response == false){
echo('Well, crap');
$info = curl_getinfo($curl);
echo('<pre>');print_r($info);echo('</pre>');
echo('<pre>');print_r(curl_error($curl));echo('</pre>');}
else {
echo('Test: ' . $curl_response);}

curl_close($curl);

我收到以下错误:

error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure

我已验证我正在使用的 Auth Token 是我在注册我的应用程序时发给我的(今天完成)。

我错过了什么吗?大多数问题和答案都与 SurveyMonkey API 的 V2 相关。我正在使用 V3。

感谢您的帮助!

【问题讨论】:

  • 问题似乎与您的令牌或任何东西无关,似乎是 TLS 错误,请确保您的服务器具有受支持的密码。您可以在此处查看 SurveyMonkey 支持的内容:ssllabs.com/ssltest/…。对于测试,如果你真的需要,你可以禁用握手验证。
  • 谢谢!我相信你是对的。当它工作时,我会发布解决方案并感谢你......
  • 不高兴。我正在使用 OpenSSL v 0.9.8c 和 TLS1.0。需要升级吗?
  • 为了清楚起见,我编辑了我的代码以设置以下内容: curl_setopt($curl, CURLOPT_SSLVERSION, 4); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); -- 还是一样的错误
  • 我不确定具体细节,但我认为您现在需要 TLS1.2,或者至少使用上面链接中指定的受支持密码。根据我发给你的链接,TLS 1.0/1.1 支持的密码只有TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,但我不是 SSL 专家。

标签: php api handshake surveymonkey


【解决方案1】:

我不确定这是否有助于解决您遇到的特定错误,但您是否尝试过使用此 API 包装器? https://github.com/ghassani/surveymonkey-v3-api-php

这个 API 包装器大大简化了我的任务:

<?php

// Init the client.
$client = Spliced\SurveyMonkey\Client(MY_CLIENT_ID, MY_ACCESS_TOKEN);

// Get a specific survey.
$survey = $client->getSurvey(MY_SURVEY_ID);

// Get all responses for this survey.
/** @var Spliced\SurveyMonkey\Response $responses */
$responses = $client->getSurveyResponses(MY_SURVEY_ID);

// Get a specific response.
/** @var Spliced\SurveyMonkey\Response $response */
$response = $client->getSurveyResponse(MY_SURVEY_ID, RESPONSE_ID, TRUE);

/* etc... */

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-05-04
    • 1970-01-01
    • 1970-01-01
    • 2017-01-02
    • 2016-05-02
    • 2021-12-21
    • 2016-06-20
    相关资源
    最近更新 更多