各位大家好!我在最近用PHP和file_get_contents编码时遇到了一个问题.我的问题是当我加载这样的网站时:
<? echo file_get_contents($_GET['url']); ?>
Run Code Online (Sandbox Code Playgroud)
我加载的网站图片没有显示.例如,当我去谷歌时,没有显示图片.这是我访问的每个网站.我怎样才能解决这个问题?
因为我无法找到问题的确切答案,所以我决定在这里寻求帮助.所以,我有一个页面内容,我得到file_get_contents并想要preg_match这个网址:
http://sample.com/Last/LastSearch.ashx?q=cnt=1&day=5&keyword=sample&location=15&view=v
Run Code Online (Sandbox Code Playgroud)
从
<a href="javascript:LastURL('http://sample.com/Last/LastSearch.ashx?q=cnt=1&day=5&keyword=sample&location=15&view=v');" id="Last" rel="nofollow" class="Last" onclick="javascript:hideCss('LastCSS');hideCss('FirstRCSS');">Last</a>
Run Code Online (Sandbox Code Playgroud)
请帮我.
当我开发网站时,我使用一个非常(非常)简单的创建页面的系统:
//$_page is, of course, declared above the loop, just as $needed_modules is.
foreach ($needed_modules as $part)
{
global $_page;
if (file_exists($part)) {
$_page . file_get_contents($part);
} else {
//404
}
}
echo $_page;
Run Code Online (Sandbox Code Playgroud)
现在,问题是file_get_contents没有返回任何内容:不是false,不是字符串,nada(文件不是空的).
执行确实进入if和$部分(对应于具有相对路径的文件名)不仅设置,但它实际上指向文件.
为什么$ _page是空的(而不是设置,isset($ _ page)实际评估为TRUE)?
编辑:错误报告在我的服务器上全速,并且日志显示没有任何异常.
file_get_contents无法使用批量请求从Facebook获取fata.使用以下代码:
$url='https://graph.facebook.com/?batch=[{ "method": "POST", "relative_url":"method/fql.query?query=SELECT+first_name+from+user+where+uid=12345678"}]& access_token=xxxxxxx&method=post';
echo $post = file_get_contents($url,true);
it produces
Warning: file_get_contents(graph.facebook.com/?batch=[{ "method": "POST", "relative_url": "method/fql.query?query=SELECT+first_name+from+user+where+uid=12345"}]&access_to? ?ken=xxxx&method=post): failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in /home/user/workspace/fslo/test.php on line 9
Run Code Online (Sandbox Code Playgroud) 我的问题是下面,我有一个EmailReports.php我的服务器上,我用它来发送类似EmailReports.php?who=some@gmail.com&what=123456.pdf邮件
我不能修改EmailReports.php,因为它属于一个不同的项目,它会立即发送一封电子邮件,并且已经被QA团队和所有这些东西批准了.
现在,在一个不同的LookReports.php上我需要提供一个服务,比如"发给我我回复的报告",只需调用EmailReports.php即可轻松执行,问题是,如何通过PHP代码完成?所以它会自动调用其他PHP.
我试过没有成功:
$stuff = http_get("http://...<the url here>");
Run Code Online (Sandbox Code Playgroud)
和
$stuff = file_get_contents("http://...<the url here>");
Run Code Online (Sandbox Code Playgroud)
我正在考虑导入EmailReports.php但由于没有功能似乎不正确,它会自动发送电子邮件.
或者我可以复制EmailReports.php代码,但这违反了QA政策,因为需要额外的测试.
你能引导我一下吗?
提前致谢.
我有使用的问题Json:http://api.justin.tv/api/stream/list.json?channel = Herdyn,我需要获得一些关于直播的信息.我的代码:
<?php
$json = file_get_contents('http://api.justin.tv/api/stream/list.json?channel=Herdyn');
$obj = json_decode($json);
echo $obj->{'name'};
?>
Run Code Online (Sandbox Code Playgroud)
当我在服务器上传它:http://blx.patrikpapso.com/herdyn/,没有错误,只是空白页,不知道该怎么办...
在我的php文件中,我使用$ _GET参数在我的服务器上打开一个文件,如下所示:
$filename = $_GET["filename"];
$content = file_get_contents("/path_to_files/".$filename);
Run Code Online (Sandbox Code Playgroud)
我的问题是,如何使这更安全,以便用户无法访问服务器上父文件夹中的文件?这是我需要在服务器上执行的操作,例如权限和/或配置吗?或者应该$filename在我的php文件中验证?提前致谢!
有没有替代file_get_contents?这是我遇到问题的代码:
if ( !$img = file_get_contents($imgurl) ) { $error[] = "Couldn't find the file named $card.$format at $defaultauto"; }
else {
if ( !file_put_contents($filename,$img) ) { $error[] = "Failed to upload $filename"; }
else { $success[] = "All missing cards have been uploaded"; }
}
Run Code Online (Sandbox Code Playgroud)
我尝试使用cURL,但无法弄清楚如何完成这项工作.任何帮助表示赞赏!
我试图找到一种无需cURL的方法,通过http web请求将数据发送到第三方支付网关.我开发了以下代码,实际上它与接收页面成功通信,但显然POST数据没有被发送.
<?php
function makeWebRequest()
{
//URL where to send the data via POST
$url = 'http://localhost/connect_to_gateway/receive.php';
//the actual data
$xml = '<?xml version="1.0" encoding="UTF-8"?>' .
'<test>' .
'Hi there!' .
'</test>';
$data = array('xml' => $xml);
//prepare the HTTP Headers
$content_type = 'text/xml';
$data = http_build_query($data);
// use key 'http' even if you send the request to https://...
$options = array(
'http' => array(
'method' => 'POST',
'header' => 'Content-type: ' . addslashes($content_type) .'\r\n'
. 'Content-Length: ' . strlen($data) …Run Code Online (Sandbox Code Playgroud) 我收到以下错误,并且正在使用WAMP并使用PHP 5.6.19版托管本地服务器
警告:file_get_contents():无法找到包装器“ https”-在配置PHP时是否忘记启用它?
php ×9
callback ×1
curl ×1
http-get ×1
http-headers ×1
image ×1
javascript ×1
json ×1
postdata ×1
preg-match ×1
scope ×1
security ×1
web-services ×1
xml ×1