2011-05-21 99 views
0

我正在提供类似于facebook share的选项,其中外部网页内容(来自外部页面的内容)可以显示在我的网站中。我正在使用PHP和Ajax进行编码。但是当我将我的页面托管在免费服务器网站上时,如www/0009.ws,我收到如下错误,file_get_contents,服务器上的CURL设置

Warning:file_get_contents()[function.file-get-contents]:URL文件访问被禁用在/www/0009.ws

的服务器配置稍后我肯定会将此迁移到付费服务器, 如果付费服务提供商也不允许我使用这些选项,是否有解决方法? 我是否必须设置自己的服务器?

回答

0

可以使用curl组函数:

<?php 
// create a new cURL resource 
$ch = curl_init(); 

// set URL and other appropriate options 
curl_setopt($ch, CURLOPT_URL, "http://www.example.com/"); 
curl_setopt($ch, CURLOPT_HEADER, 0); 

// grab URL and pass it to the browser 
curl_exec($ch); 

// close cURL resource, and free up system resources 
curl_close($ch); 
?> 

假设是内置的,这是一个有点吃不消。老实说file_get_contents没有URL文件访问是你在选择提供商之前应该检查的东西。