[英]cURL is not working on live server
我正在尝试使用PHP
和cURL
在IOS
发送推送通知,但是curl
在我的实时服务器上不起作用,尽管在服务器上启用了curl扩展,这是我的通知文件curl代码!
<?php
error_reporting(E_ALL);
$message = "Test Notifcation";
$regId = $_REQUEST['device_id'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://examplemyserver.com/api/push.php");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER["HTTP_USER_AGENT"]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_VERBOSE, true);
$data = array(
'deviceToken' => $regId,
'title' => "send_notification",
'message' => $message,
'notification_id' => "test",
'notification_title' => "test1",
'notification_description' => "lorem",
'sent_date' => strtotime(date("Y-m-d H:i:s"))
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
var_dump(curl_getinfo($ch));
print_r(curl_error($ch));
$output = curl_exec($ch);
echo 'Curl error: ' . curl_error($ch);
curl_close($ch);
print_r($output);
?>
每当我尝试使用上面的代码运行通知文件时,它花费了超过30秒并显示以下错误:
array(26) {
["url"]=>
string(50) "http://examplemyserver.com/api/push.php"
["content_type"]=>
NULL
["http_code"]=>
int(0)
["header_size"]=>
int(0)
["request_size"]=>
int(0)
["filetime"]=>
int(0)
["ssl_verify_result"]=>
int(0)
["redirect_count"]=>
int(0)
["total_time"]=>
float(0)
["namelookup_time"]=>
float(0)
["connect_time"]=>
float(0)
["pretransfer_time"]=>
float(0)
["size_upload"]=>
float(0)
["size_download"]=>
float(0)
["speed_download"]=>
float(0)
["speed_upload"]=>
float(0)
["download_content_length"]=>
float(-1)
["upload_content_length"]=>
float(-1)
["starttransfer_time"]=>
float(0)
["redirect_time"]=>
float(0)
["redirect_url"]=>
string(0) ""
["primary_ip"]=>
string(0) ""
["certinfo"]=>
array(0) {
}
["primary_port"]=>
int(0)
["local_ip"]=>
string(0) ""
["local_port"]=>
int(0)
}
卷曲错误:
Failed to connect to examplemyserver.com port 80: Connection refused
您能建议我什么问题,服务器配置有什么变化?
尝试添加此行
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
之前
var_dump(curl_getinfo($ch));
如果仍然无法使用,请确保您的url
正确。
可能是您在服务器上设置了firewall
,从而阻止了与*:80
连接-与外部服务器端口80的所有连接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.