HostGator无法通过cURL连接到Amazon API [英] HostGator won't connect via cURL to an Amazon API

查看:81
本文介绍了HostGator无法通过cURL连接到Amazon API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码在我可以访问并用于在Hostgator上运行的其他2台服务器上没有问题。
Hostgator技术支持拒绝帮助,因为他们认为这是代码问题。
除非将HTTPS更改为HTTP,否则我不会从API得到任何响应,在这种情况下,我会从cloudfront.net收到307重定向消息。
对解决方案有什么想法吗?

The following code executes no problem on 2 other servers I have access to and use to run on Hostgator. Hostgator tech support refuse to help as they feel it's an issue with the code. I get no response from the API unless I change the HTTPS to HTTP in which case I get a 307 redirect message from cloudfront.net. Any ideas on what a solution might be?

$data = array(
  "status" => "Quote",
  "job_address" => "1 Infinite Loop, Cupertino, California 95014, United States",
  "job_description" => "Client has requested quote for service delivery"
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.servicem8.com/api_1.0/Job.json');
curl_setopt($ch, CURLOPT_USERPWD, "xxx@xxxxx.com:password");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_VERBOSE , true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Accept: application/json'));

$response = curl_exec($ch);
var_dump($response);


推荐答案

我的问题的答案相当具体。简而言之,我在Hostgator环境上运行PHP5.4,不允许发生适当的SSL握手...
解决方案是升级到PHP 5.6

The answer to my problem was fairly specific. In short, I was running PHP5.4 on my Hostgator environment which was not allowing appropriate SSL handshakes to happen... The solution was to upgrade to PHP 5.6

这篇关于HostGator无法通过cURL连接到Amazon API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆