调用SurveyMonkey API V3的PHP握手错误

问题描述:

我是REST的新用户,他的任务是使用V3 API检索SurveyMonkey调查数据。我正在使用PHP。我的代码如下:调用SurveyMonkey API V3的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 

我已经验证了我使用的身份验证令牌是一个发给我,当我登记我的应用程序(目前完成)。

我错过了什么吗?大部分问题和答案都涉及SurveyMonkey API的V2。我正在使用V3。

感谢您的帮助!

+0

问题看起来与你的令牌或什么不是,似乎是一个错误TLS,请确保您的服务器所支持的加密算法。您可以在这里查看SurveyMonkey支持的内容:https://www.ssllabs.com/ssltest/analyze.html?d=api.surveymonkey.net&latest。对于*测试*如果您确实需要,您可能会禁用握手验证。 –

+0

谢谢!我相信你是对的。当它工作时,我会发布解决方案,并奖励你... – dneimeier

+0

没有快乐。我正在使用OpenSSL v 0.9.8c和TLS1.0。需要升级吗? – dneimeier

我不确定这是否会帮助你遇到的具体错误,但你有没有尝试过使用这个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... */