Skip to content

reeze/php5-xcom

 
 

Repository files navigation

php5-xcom

X.Commerce message handling extension for PHP5

Installing/Configuring

Debian pkg's are provided under debs/

$ phpize && ./configure
$ make && sudo make install
# echo "extension=xcom.so" >> /your/php.ini

A gcc-like toolchain, php headers, and libavro are required.

Examples

Sending a message to X.commerce:

<?php

$data = new stdClass();
$data->member_id = 123495585343;

$xcom = new Xcom("http://api.sandbox.x.com/fabric/", "fabric_token",
"capability_token");

var_dump($xcom->send("/topic/", $data, '{"json": "schema"}'));

/*
 * Output:
 * int(200)
 */

?>

Receiving a message from X.commerce:

<?php

$xcom = new Xcom("http://api.sandbox.x.com/fabric/", "fabric_token",
"capability_token");

var_dump($xcom->decode(file_get_contents("php://input"), '{"json": "schema"}'));

/*
 * Output:
 * object(stdClass)#87 (2) { ["username"]=> string(2) "hi" ["active"]=> int(38347473) }
 */
?>

Debugging:

<?php

$xcom = new Xcom("http://api.sandbox.x.com/fabric/", "fabric_token",
"capability_token");

$xcom->__debug = true;

$xcom->send($topic, $data, '{"json": "schema"}');
var_dump($xcom->getDebugOutput());

?>

Encoding a message:

<?php

$data = new stdClass();
$data->member_id = 123495585343;

$xcom = new Xcom("http://api.sandbox.x.com/fabric/", "fabric_token",
"capability_token");

var_dump($xcom->encode($data, '{"json": "schema"}'));

/*
 * Output:
 * a binary string that contains an avro message, which can be POST'ed to
 * X.Commerce
 */

?>

About

X.Commerce message handling extension for PHP5

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 57.2%
  • Shell 41.3%
  • Other 1.5%