标签: file-get-contents

file_get_contents - 也可以获取图片

各位大家好!我在最近用PHP和file_get_contents编码时遇到了一个问题.我的问题是当我加载这样的网站时:

<? echo file_get_contents($_GET['url']); ?>
Run Code Online (Sandbox Code Playgroud)

我加载的网站图片没有显示.例如,当我去谷歌时,没有显示图片.这是我访问的每个网站.我怎样才能解决这个问题?

php image file-get-contents

0
推荐指数
1
解决办法
4590
查看次数

preg_match url模式

因为我无法找到问题的确切答案,所以我决定在这里寻求帮助.所以,我有一个页面内容,我得到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)

请帮我.

javascript php file-get-contents preg-match

0
推荐指数
1
解决办法
1705
查看次数

PHP中的get_file_contents和范围问题

当我开发网站时,我使用一个非常(非常)简单的创建页面的系统:

//$_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)?

编辑:错误报告在我的服务器上全速,并且日志显示没有任何异常.

php scope file-get-contents

0
推荐指数
1
解决办法
67
查看次数

file_get_contents无法使用批量请求从Facebook获取数据

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)

php file-get-contents facebook-batch-request

0
推荐指数
1
解决办法
4786
查看次数

如何从PHP调用网站服务?

我的问题是下面,我有一个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政策,因为需要额外的测试.

你能引导我一下吗?

提前致谢.

php web-services http-get callback file-get-contents

0
推荐指数
1
解决办法
1672
查看次数

PHP> File_get_contents + json_decode不起作用

我有使用的问题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 json file-get-contents

0
推荐指数
1
解决办法
6597
查看次数

验证file_get_contents PHP的用户输入

在我的php文件中,我使用$ _GET参数在我的服务器上打开一个文件,如下所示:

$filename = $_GET["filename"];
$content = file_get_contents("/path_to_files/".$filename);
Run Code Online (Sandbox Code Playgroud)

我的问题是,如何使这更安全,以便用户无法访问服务器上父文件夹中的文件?这是我需要在服务器上执行的操作,例如权限和/或配置吗?或者应该$filename在我的php文件中验证?提前致谢!

php security file-get-contents

0
推荐指数
1
解决办法
995
查看次数

有没有替代file_get_contents?

有没有替代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,但无法弄清楚如何完成这项工作.任何帮助表示赞赏!

php curl file-get-contents

0
推荐指数
1
解决办法
3878
查看次数

PHP - 使用无cURL的http Web请求向网关发布XML数据

我试图找到一种无需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)

xml postdata httpwebrequest file-get-contents http-headers

0
推荐指数
1
解决办法
6901
查看次数

HTTP包装上PHP错误

我收到以下错误,并且正在使用WAMP并使用PHP 5.6.19版托管本地服务器

警告:file_get_contents():无法找到包装器“ https”-在配置PHP时是否忘记启用它?

php file-get-contents

0
推荐指数
1
解决办法
7917
查看次数