除了 CURL 之外,其他客户端还有其他选择吗? [英] Are there any other options for rest clients besides CURL?

查看:52
本文介绍了除了 CURL 之外,其他客户端还有其他选择吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

PHP 中是否有 CURL 的替代方案,允许客户端连接到 REST 架构服务器?

Are there alternatives to CURL in PHP that will allow for a client to connect o a REST architecture server ?

PUT、DELETE、文件上传是一些需要工作的事情.

PUT, DELETE, file upload are some of the things that need to work.

推荐答案

您可以编写自己的库.甚至可以完全在 PHP 中完成,使用 fsockopen 和朋友.例如:

You can write your own library. It's even possible to do it completely in PHP, using fsockopen and friends. For example:

function httpget($host, $uri) {
  $msg = 'GET '.$uri." HTTP/1.1\r\n".
         'Host: '.$host."\r\n".
         "Connection: close\r\n\r\n";
  $fh = fsockopen($host, 80);
  fwrite($fh, $msg);
  $result = '';
  while(!feof($fh)) {
    $result .= fgets($fh);
  }
  fclose($fh);
  return $result;
}

这篇关于除了 CURL 之外,其他客户端还有其他选择吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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