可能的重复:
file_get_contents() 错误 https://stackoverflow.com/questions/6551379/file-get-contents-error
编写一个连接到 Instagram API 的脚本,以从某个标签获取照片。它在本地运行良好,但在服务器上出现错误。
警告:file_get_contents():第 19 行 /storage/content/91/103391/instaboll.nu/public_html/instagram.php 中的allow_url_fopen=0 在服务器配置中禁用了 https:// 包装器。
第 19 行是这样的:
$内容 = file_get_contents("https://api.instagram.com/v1/tags/ https://api.instagram.com/v1/tags/$tag/media/recent?client_id=$client_id");
有任何想法吗?
已经搜索过这个并找到一些推荐curl的帖子,但不知道如何继续。
我用这段代码解决了它。
<?php
$url = "http://www.example.org/";
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
$contents = curl_exec($ch);
if (curl_errno($ch)) {
echo curl_error($ch);
echo "\n<br />";
$contents = '';
} else {
curl_close($ch);
}
if (!is_string($contents) || !strlen($contents)) {
echo "Failed to get contents.";
$contents = '';
}
echo $contents;
?>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)