Download Orders from Pixmania Marketplace

# code snippet, Trevor O Connell, 2008
$oCurl = curl_init();

# Use your correct secret serial ID here. Pix Marketplace will supply these when
# you sign up.
$sSerial = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$sHttpLogin = 'pixloginaccount';
$sHttpPwd = 'pixpassword';

print "Downloading Pixmania UK Order File\n";

$sCalledurl = 'https://pixplace-ws.pixmania.com/index.php?d=webServices_Server&c=ServerRest&rm=exportFile&rf=exportOrdersToDeliver&site_id=1&sl='.$sSerial;

try
{
//Option: Url to call
curl_setopt( $oCurl, CURLOPT_URL, $sCalledurl );

//Option: Do not display the result but store it in a variable
curl_setopt( $oCurl, CURLOPT_RETURNTRANSFER, 1);

//Option: Set HTTPS Login And password
curl_setopt( $oCurl, CURLOPT_USERPWD, $sHttpLogin.':'.$sHttpPwd );
curl_setopt( $oCurl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt( $oCurl, CURLOPT_UNRESTRICTED_AUTH, true);

curl_setopt( $oCurl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt( $oCurl, CURLOPT_SSL_VERIFYPEER, false);

//Launch Curl Request
$sCurlResponse = curl_exec( $oCurl );

if ($sCurlResponse != "" )
{
$fp = fopen('./PixmaniaUK/Downloads/'.date("Y.m.d_H:i").'_orders.csv', 'w');
fwrite($fp, $sCurlResponse);
fclose($fp);
}
}
catch (Exception $e)
{
WriteLog("Error downloading orders from PIXMANIAUK");
WriteLog("Exception Caught:". $e->getMessage());
}

exit();

#======================================================
# User Defined Functions
#======================================================
function WriteLog($msg)
{
$error = "[".date("d/m/y H:i:s")." -- PIXMANIAUK] : ".$msg."\n";
error_log($error, 3, "/var/log/webservices.log");
return;
}

function get_xml_tag_value($xml,$tag)
{
preg_match('/<$tag(.*)?>(.*)?<\/$tag>/', $xml, $match);
$value=$match[0];
return $value;
}


?>

Comments

Popular posts from this blog

Basic Send Message to MQ with Java and IBM MQ JMS

Basic Receive Message to MQ with Java and IBM MQ JMS

Configure Database Connection using MyBatis