steveosoule
8/13/2015 - 5:59 PM

Miva - Basic Remote Provisioning cURL with PHP

Miva - Basic Remote Provisioning cURL with PHP

<?php
// ini_set('error_reporting', E_ALL);
// In Miva Admin, set Allowed IP Address(es) to "0.0.0.0/0" to allow any IP (for debugging only)

define('POSTURL', 'https://www.example.com/mm5/json.mvc?Function=Module&Module_Code=remoteprovisioning&Module_Function=XML' );
define('ACCESSTOKEN', '00000000000000000000000000000000' );
define('STORE_CODE', 'ABC' );


$xml = '<Provision><Store code="'.STORE_CODE.'">';

// Add Custom Provision Here

$xml .= '</Store></Provision>';

$ch = curl_init(POSTURL);
curl_setopt($ch, CURLOPT_POST ,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS ,$xml);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION ,1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
	'Content-type: text/xml',
	'MMProvision-Access-Token: ' . ACCESSTOKEN,
	'Content-length: ' . strlen($xml)
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1);
$response = curl_exec($ch);
curl_close($ch);

header('Content-type: text/xml');
echo $response;

?>