file_get_contents()用于短网址 [英] file_get_contents() for short urls

查看:129
本文介绍了file_get_contents()用于短网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

file_get_contents()不会读取短网址的数据
示例:

file_get_contents() doesn't read data for short urls Example:


  • http://wp.me/pbZy8-1WM,

  • http://bit.ly/d00E2C

请帮我处理这个。 OR是否有任何CURL函数来处理上述链接?

Please help me in handle this. OR Is there any CURL function to handle above links?

推荐答案

如果你发现它做不正确的事情,你可以明确使用流上下文:

This in general works fine. If you find it doesn't do the right thing you can explicitly use a stream context:

$url = "http://bit.ly/d00E2C";
$context = stream_context_create(array('http' => array('max_redirects' => 5)));
$val = file_get_contents($url, false, $context);

不需要触摸CURL。

这篇关于file_get_contents()用于短网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆