基于PHP的thrift API客户端,类似thirft.apache.org的Python示例客户端

0 投票
1 回答
1011 浏览
提问于 2025-04-17 06:56

我想写一个基于PHP的thrift API客户端,类似于在这个网站上用Python写的示例客户端:http://thrift.apache.org/

我写了以下代码:

      //A struture
      $up = UserProfile($uid=1,
             $name="Mark Slee",
             $blurb="I'll find something to put here.");

      # Talk to a server via TCP sockets, using a binary protocol
      $fp = fsockopen("localhost",9090, $errno, $errstr, 90);
      # Use the service we already defined
      $service=fwrite($fp, $up);

      while (!feof($fp)) {
          echo fgets($fp, 128);
      }

那么这段代码是否可以作为Python客户端代码的正确替代呢?在这里可以查看Python的示例:http://thrift.apache.org/

因为我对这个还很陌生,所以请给我一些建议。

谢谢!

1 个回答

2

去看看 Thrift Wiki 上的 Thrift 使用 页面。那里有很多支持的编程语言的例子,特别是有一个 PHP 的示例客户端

撰写回答