Skip to content

Herman J. Radtke III

Facebook Thrift PHP Client

A while back I wrote a post about using Facebook's Thrift.  One comment asked me to post the PHP client used to connect to the C++ server I was demo'ing.  Most of the client is boiler-plate code generated by Thrift, so I chose to omit it at the time.  Here it is:

#!/usr/bin/env php

  $d = new Sale_deal();

  $d->dealno = 12345;
  $d->term = 2;
  $d->payment = 500.1;
  $d->amtfin = 1000.00;

  echo 'Total cost: ' . $client->calc_apr($d) . "\n";


} catch (TException $tx) {
  print 'TException: '.$tx->getMessage()."\n";