基于PHP的thrift API客户端,如python中的thirft.apache.org示例客户端

时间:2011-11-23 19:19:35

标签: php python thrift thrift-protocol

我想在python中编写基于PHP的thrift API客户端,例如thirft.apache.org示例客户端: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客户端代码的正确替代品:http://thrift.apache.org/

请提出任何建议,因为我是新手。

感谢

1 个答案:

答案 0 :(得分:2)

查看Thrift Wiki页面上的Thrift Usage。这有很多支持语言的例子,特别是example client in PHP