0

我正在编写一个网络应用程序,并且我已将短信集成到我的代码中。我的应用程序在我的本地主机上完美运行,我可以通过 curl 或 php 中的 file_get_contents 发送 http 请求,获取响应并处理它。

但是,我刚刚托管了该站点,并且由于它是在线托管的,因此在发送 http 请求时遇到了问题。我用 curl 和 file_get_contents 尝试过,但没有成功。

然后我决定将站点托管在来自不同提供商的另一台服务器上,但我仍然无法发送请求。我也没有收到任何错误消息。我一直在我的本地主机上对其进行测试,以确保它不是来自脚本,并且我 100% 确定它不是来自我的代码。

我联系了客户支持,但他们没有任何帮助。

我真的被困住了,我需要帮助。谢谢你。请从我用来提出以下请求的代码中找到摘录:

假设变量已经定义...

<?php
.................................

// the url contains my password and username so i took it off
$url = "";
$response = file_get_contents($url);

/*
// this is the curl part and it works if I decide to use it instead
$ch = curl_init($url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
$response = curl_exec($ch);
curl_close($ch);
*/
$result = explode("|", $response);
4

1 回答 1

1

file_get_contents()它经常被 IT 部门和托管服务提供商禁用,因为如果不小心使用它可能会导致地狱。那将是我要检查的第一件事。

于 2013-02-01T23:14:05.333 回答