duanpao4522 2015-01-20 21:50
浏览 39
已采纳

是否有任何方法可以在最流行的托管选项中生成服务器到服务器的http请求?

I would like to be write a script that can be used by people that have a variety of hosting providers. The script needs to be able to make a http-get (or post) request.

I have seen warnings in various places that php's, curl() and fopen() may not be enabled on some hosts. How common is it for these to be disabled? Are they available, e.g. in wordpress's hosting?

If they are frequently disabled, is there an alternative method for performing a http request from the server that is not?

Thanks in advance!

  • 写回答

1条回答 默认 最新

  • duanca3415 2015-01-20 22:17
    关注

    A wise way would be to stubbornly check all possible methods:

    if(function_exists('curl_init'))
        use curl
    else if ini_get('allow_url_fopen')
        use files
    else if function_exists('fsockopen')
        use sockets
    else
        echo 'hey, it's about time to change the hoster!'
    

    Specifically to Wordpress, it heavily relies on server-to-server communication (think updates, pingbacks, Akismet etc), therefore most hosters do allow it.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 adb连接不到手机是怎么回事?
  • ¥15 vs2022无法联网
  • ¥15 TCP的客户端和服务器的互联
  • ¥15 VB.NET操作免驱摄像头
  • ¥15 笔记本上移动热点开关状态查询
  • ¥85 类鸟群Boids——仿真鸟群避障的相关问题
  • ¥15 CFEDEM自带算例错误,如何解决?
  • ¥15 有没有会使用flac3d软件的家人
  • ¥20 360摄像头无法解绑使用,请教解绑当前账号绑定问题,
  • ¥15 docker实践项目