2011-04-01 05:51
浏览 111


i need to open the following url

$file = ""; 

$fp = fopen($file, "r"); 

but i am geeting warning http request failed/ 403 forbidden

图片转代码服务由CSDN问答提供 功能建议


  $ file =  “”;  
 $ fp = fopen($ file,“r”);  

但我警告警告http请求失败/ 403禁止

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • doucang6914 2011-04-01 06:17

    but i am geeting warning http request failed/ 403 forbidden

    The 403 error is coming from their server.

    Chances are that you or someone on the IP address or block you are using has been aggressively banned from using the Wikipedia API. You will need to contact a responsible admin at Wikipedia to investigate.

    打赏 评论
  • dpz7935 2011-04-01 05:56

    What do you need the file for? If you just need the output, you can try file_get_contents() instead, and then load and manipulate it as a string instead of a file.

    打赏 评论
  • dougou8573 2011-04-01 11:10

    The default PHP user agent is blocked; see Wikimedia's User-Agent policy for details. You can easily enough change your user agent using ini_set at the top of your script, like this:

    ini_set("user_agent", "Testing for");

    Do note that the English Wikipedia forbids downloading many pages via the API (offering database dumps instead), and that automated processes that actually edit the wiki are forbidden unless approved. See their bot policy for details.

    打赏 评论

相关推荐 更多相似问题