Skip to content

Instantly share code, notes, and snippets.

Created June 11, 2011 20:37
What would you like to do?
// You can see the example lookup here:
function getAvailablePricePoints($countries) {
//Get Price Look Up table per country in $countries
foreach ($countries as $countryCode) {
$requestXML = "<?xml version='1.0' encoding='UTF-8'?>
<requestMobilePaymentProcessEntrypoints xmlns='' xmlns:xsi='' xsi:schemaLocation=''>
<items currency='USD' />
//Prepare XML string to be sent as "request" POST parameter
$postVars = "request=$requestXML";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$this->priceLookUpUrl);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postVars);
curl_setopt($ch, CURLOPT_FAILONERROR,1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
$rawXml = curl_exec($ch); //TODO: check that response is correct
//Cache Response. For demo only, flat files are used.
$filename = "zong" . $countryCode . ".txt";
$file = fopen($filename,'a') OR die ("Can't open file\n");
fwrite ($file, $rawXml);
fclose ($file);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment