bly*_*ung 7 php file-get-contents
可能重复:
file_get_contents()错误
处理连接到Instagram API的脚本以从特定标签获取照片.它在Local上工作正常,但在服务器上我得到错误.
警告:在第19行的/storage/content/91/103391/instaboll.nu/public_html/instagram.php中,allow_url_fopen = 0在服务器配置中禁用了file_get_contents():https://包装器.
第19行看起来是这样的:
$ contents = file_get_contents(" https://api.instagram.com/v1/tags/ $ tag/media/recent?client_id = $ client_id");
有任何想法吗?
已搜索过这个并找到一些推荐curl的帖子,但不知道如何继续.
bly*_*ung 17
我用这个代码解决了它.
<?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;
?>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
30606 次 |
| 最近记录: |