我无法在实时服务器上使用 curl 方法 运行 和 api
I am not able to run an api using curl method on live server
在本地主机短信工作
我使用 curl 来点击 api,我在本地主机上尝试了这个方法,它工作正常,但是当我将相同的方法复制到实时网站时,它停止在实时上工作网站。
$味精="Some Custom msg here";
$msgencoded = urlencode($msg);
// 消息已编码
$numEncode = urlencode($telePhone);
// 电话已编码
注意:我正确地获取了这个变量。 $telephone
API 根据 API 文档
$url = "http://msg_server_website.com:8080/SMSAPI.jsp?
username=user_name&
password=user_pwd&
sendername=sender_name&
mobileno=".$numEncode."&message=".$msgencoded."";
My curl function which is working on localhost.
$data = $msg;
$crl = curl_init();
curl_setopt($crl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($crl, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($crl, CURLOPT_URL, $url);
curl_setopt($crl, CURLOPT_HEADER, 0);
curl_setopt($crl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($crl, CURLOPT_POST, 1);
curl_setopt($crl, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($crl);
if ($response) {
// if curl_exec() returned false and thus failed
echo 'everything was successful';
}
else {
echo 'An error has occurred: ' . curl_error($crl);
}
curl_close($crl);
更新 1:
error has occurred: Failed to connect to websitename.com port 8080: Connection refused
我尝试了很多次都遇到了这个错误。在这种情况下该怎么办。
更新 2
8080 端口在客户端服务器上被阻止。做什么,如何解锁端口。
更新 3
我的问题现在已经解决了,就我而言,它的 8080 端口问题在客户端主机上不是免费的,现在一切都按预期工作。
谢谢大家的支持
为了结束这个 post,我 post 将这个作为答案。
我的问题现在已经解决了,就我而言,它的 8080 端口问题在客户端主机上不是免费的,现在一切正常。
我咨询了服务器提供商(在这种情况下是 Godady)。由于客户端使用共享主机,因此无法为个人释放端口。
所以我与短信提供商进行了交谈,他们建议对端口和我的 API 进行一些更改,现在 运行 成功了。
在本地主机短信工作
$味精="Some Custom msg here";
$msgencoded = urlencode($msg);
// 消息已编码
$numEncode = urlencode($telePhone);
// 电话已编码
注意:我正确地获取了这个变量。 $telephone
API 根据 API 文档
$url = "http://msg_server_website.com:8080/SMSAPI.jsp?
username=user_name&
password=user_pwd&
sendername=sender_name&
mobileno=".$numEncode."&message=".$msgencoded."";
My curl function which is working on localhost.
$data = $msg;
$crl = curl_init();
curl_setopt($crl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($crl, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($crl, CURLOPT_URL, $url);
curl_setopt($crl, CURLOPT_HEADER, 0);
curl_setopt($crl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($crl, CURLOPT_POST, 1);
curl_setopt($crl, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($crl);
if ($response) {
// if curl_exec() returned false and thus failed
echo 'everything was successful';
}
else {
echo 'An error has occurred: ' . curl_error($crl);
}
curl_close($crl);
更新 1:
error has occurred: Failed to connect to websitename.com port 8080: Connection refused
我尝试了很多次都遇到了这个错误。在这种情况下该怎么办。
更新 2
8080 端口在客户端服务器上被阻止。做什么,如何解锁端口。
更新 3 我的问题现在已经解决了,就我而言,它的 8080 端口问题在客户端主机上不是免费的,现在一切都按预期工作。
谢谢大家的支持
为了结束这个 post,我 post 将这个作为答案。
我的问题现在已经解决了,就我而言,它的 8080 端口问题在客户端主机上不是免费的,现在一切正常。
我咨询了服务器提供商(在这种情况下是 Godady)。由于客户端使用共享主机,因此无法为个人释放端口。
所以我与短信提供商进行了交谈,他们建议对端口和我的 API 进行一些更改,现在 运行 成功了。