Last active
December 16, 2015 14:29
-
-
Save ltvolks/5448848 to your computer and use it in GitHub Desktop.
AMP PHP client example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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