标签: file-get-contents

File_get_contents不起作用?

我正在使用cakephp.我正在尝试使用file_get_contents从facebook获取数据.我收到警告

警告(2):file_get_contents()[function.file-get-contents]:在服务器配置中禁用URL文件访问警告(2):file_get_contents(https://graph.facebook.com/XXXXXXX/?access_token= 111978178XXXXXX |.2.lg65A3c0atficNsFcf7Rog __ 3600.12799XXXX-1000

有没有办法获取数据?

我感谢任何帮助.

谢谢.

php facebook cakephp file-get-contents

7
推荐指数
1
解决办法
6692
查看次数

file_get_contents()的等效函数?

我想从html页面解析一些信息.目前我解决了这样的问题:

header("Content-type: text/plain");    
$this->pageSource = file_get_contents ($this->page);
header("Content-type: text/html");
Run Code Online (Sandbox Code Playgroud)

$this->page是该网站的网址.这在XAMPP上工作正常,但是当我在我的网络服务器上传我的脚本时,我收到以下错误消息:

警告:file_get_contents()[function.file-get-contents]:http://在服务器配置中禁用包装器allow_url_fopen = 0

显然我不允许在我的网络服务器上执行该功能.

那么有一个等价的功能来解决我的问题吗?

php file-get-contents

7
推荐指数
1
解决办法
1万
查看次数

file_get_contents()错误

我在PHP上使用file_get_contents,它会抛出一些错误:

我的代码

#try to fetch from remote
$this->remotePath = "http://some-hostname.com/blah/blah.xml
$fileIn = @file_get_contents($this->remotePath);
Run Code Online (Sandbox Code Playgroud)

错误:

Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in /virtual/path/to/file/outputFile.php on line 127

Warning: file_get_contents(https://some-host-name/data/inputFile.xml) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in /virtual/path/to/file/outputFile.php on line 127
Run Code Online (Sandbox Code Playgroud)

任何的想法?它在我的计算机上工作正常但在我将其移植到Web服务器时停止工作.

php file-get-contents

7
推荐指数
2
解决办法
3万
查看次数

php - file_get_contents - 下载文件名中带空格的文件不起作用

我正在尝试使用file_get_contents()函数下载文件.但是,如果文件的位置是http://www.example.com/some name.jpg,则该功能无法下载.

但是如果URL被给出http://www.example.com/some%20name.jpg,则下载相同的URL .

我试过rawurlencode()但是这会隐藏URL中的所有字符,下载再次失败.

有人可以为此建议一个解决方案吗?

php urlencode file-get-contents

7
推荐指数
2
解决办法
1万
查看次数

什么是更快:include()或file_get_contents()?

我正在为我的项目开发一个SEO系统,并用一个页面优化所有链接.

.htaccess文件摘录:

RewriteRule ^(.+)$ seo.php [L,QSA]
Run Code Online (Sandbox Code Playgroud)

这个SEO文件(seo.php)将获取请求的路径并将其解析为我的脚本中的有效URL.

include('cat.php?catid=1')在最后使用,seo.php一切都很好,但我想知道哪个更快:include()或者file_get_contents()

当我使用file_get_content('cat.php?catid=1')它时,它显示PHP文件的来源,但是当我使用file_get_content('http://localhost/cat.php?catid=1')它时,它显示正常页面.

那么,哪个更快:file_get_content()或者include()

php include file-get-contents

7
推荐指数
1
解决办法
6833
查看次数

PHP:什么是最快的SOAP,file_get_contents或Curl?

我有网站A,它正在向网站B的每个页面加载发送请求.B服务器在mysql中进行一些内部搜索,需要将一些数据返回给服务器A,服务器A将根据该响应显示一些内容.

在这两台服务器之间进行通信的最快方法是什么?

curl soap file-get-contents

7
推荐指数
1
解决办法
1521
查看次数

我们需要关闭file_get_contents吗?

我在file_get_contents()循环中运行,我看到在Apache日志中打开了很多文件.我不知道背后的原因.file_get_contents()每次阅读后我们是否需要关闭该功能?

php file-get-contents

7
推荐指数
1
解决办法
6874
查看次数

file_get_contents和curl都不起作用

我刚刚使用file_get_contents来检索我网站上的数据.但它不会返回任何东西.

file_get_contents("https://www.google.co.in/images/srpr/logo11w.png")
Run Code Online (Sandbox Code Playgroud)

当我在我的本地环境中使用它时,它返回值.

我也尝试在我的网站上卷曲,以确定它是否返回任何东西.但它表明

禁止
您无权访问.

我用Google搜索,我发现了一些提示.我启用了allow_url_fopenallow_url_include.

但没有任何效果.

我试过的卷曲代码

function curl($url){ 
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL,$url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  $return = curl_exec($ch); curl_close ($ch);
  return $return;
} 
$string = curl('https://www.google.co.in/images/srpr/logo11w.png');
echo $string;
Run Code Online (Sandbox Code Playgroud)

php curl file-get-contents phpinfo

7
推荐指数
1
解决办法
2348
查看次数

带有空格的file_get_contents

我有一个问题,即使我将空格替换为%20并将此内容作为终极URL,浏览器将"%20"变为"%2520"

这是我的代码,任何建议让这个工作?这似乎很容易,但我卡住了:/

<?php
//$_GET['song'] will contain a song name with spaces
$song = str_replace(array("%20", "&", "?" , "/"), array(" ", "", "", ""), $_GET['song']);

// I use this to check how the GET 'song' looks after the str_replace
$list = "http://www.lyrdb.com/lookup.php?q=" . $song . "&for=fullt";
echo "list url is " . $list . "<hr>";

$content = file_get_contents("http://www.lyrdb.com/lookup.php?q=" . str_replace(" ", "%20", $song) . "&for=fullt");

echo $content;
?>
Run Code Online (Sandbox Code Playgroud)

如果你去http://webservices.lyrdb.com/lookup.php?q=red%20hot%20chili%20peppers&for=fullt结果应该输出一个歌词代码列表.

当我去我的网站/?song =红辣椒时,它也将空格转换为%20,但如果看起来浏览器将%'转换为%25.

有人可以帮我吗?

php spaces file-get-contents

6
推荐指数
1
解决办法
1万
查看次数

PHP file_put_contents:无法打开流:协议错误

使用 PHP copy 或 file_put_contents 保存图像有时会返回以下错误:无法打开流:协议错误。

这是我尝试的工作流程:

// A. using file_get_contents and file_put_contents
$image = file_get_contents('https://maps.googleapis.com/maps/api/place/photo?key=' . $apiKey . '&photoreference=' . $mainPhoto['photo_reference'] . '&maxheight=300'

file_put_contents('googleimage/' . $mainPhoto['photo_reference'] . '.jpg', $image) // here is where the exception is thrown

// B. using copy
copy('https://maps.googleapis.com/maps/api/place/photo?key=' . $apiKey . '&photoreference=' . $mainPhoto['photo_reference'] . '&maxheight=300', 'googleimages/' . $mainPhoto['photo_reference'] . '.jpg');
Run Code Online (Sandbox Code Playgroud)

这只是有时发生,仅适用于某些图片。

php copy file file-get-contents

6
推荐指数
2
解决办法
3120
查看次数

标签 统计

file-get-contents ×10

php ×9

curl ×2

cakephp ×1

copy ×1

facebook ×1

file ×1

include ×1

phpinfo ×1

soap ×1

spaces ×1

urlencode ×1