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.

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

报告相同问题?

悬赏问题

  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了