Skip to content

Instantly share code, notes, and snippets.

@ltvolks
Last active December 16, 2015 14:29
Show Gist options
  • Select an option

  • Save ltvolks/5448848 to your computer and use it in GitHub Desktop.

Select an option

Save ltvolks/5448848 to your computer and use it in GitHub Desktop.
AMP PHP client example
<?php
/*
Protocol details: http://amp-protocol.net/
Full client implementation of the protocol: http://twistedmatrix.com/trac/browser/sandbox/jerub/ampclient.php
*/
require('ampclient.php');
// Create an AMP client
$client = new AMP($host, $port);
// Ask and wait for response
$response = $client->call('BalanceInquiry', array('MID'=>'1234', 'LID'=>'0001', 'cardnumber'=>'1231231234'));
// response is a hash of return values:
echo "$response['balance_points'] points and $response['balance_gift'] dollars"
// More examples:
$response = $client->call('AddPoints', array('MID'=>'1234', 'LID'=>'0001', 'cardnumber'=>'1231231234', 'sales_amount'=>50.00));
$response = $client->call('AddPointsAndRedeem', array('MID'=>'1234', 'LID'=>'0001', 'cardnumber'=>'1231231234', 'sales_amount'=>50.00, 'redeem_reward'=>10.00, 'redeem_gift'=>25.00));
$client->close();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment