卷曲不活的服务器
问题描述:
上工作,我尝试发送推送通知使用PHP
和cURL
但curl
IOS
虽然卷曲扩展服务器上启用 我活的服务器上不工作在这里下面是我的通知文件卷曲代码!卷曲不活的服务器
<?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
能否请你建议我什么是问题,以及我在服务器配置中更改了哪些内容?前
var_dump(curl_getinfo($ch));
答
尝试加入这一行curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
如果仍不能正常工作,则请确保您url
是正确的。
答
有机会,你有一个firewall
设置被阻断*:80
连接在服务器上 - 所有连接到外部服务器的端口80
找你的连接是不成立的。你确定你使用'http'而不是'https'或者'URL'正在工作。 – Abbasi
是的,我使用http,并确保URL正在工作 – Meghna
从运行此文件的服务器上尝试'telnet examplemyserver.com 80' –