【Reward $10】somebody help me to fix my libertyreserve api

Looking to hire a PHP developer for a paid position? Looking for a paid PHP job? Want to post your resume? Let the job hunt begin...

Moderator: General Moderators

Post Reply
ck215631
Forum Newbie
Posts: 1
Joined: Sat Jan 19, 2013 12:53 am

【Reward $10】somebody help me to fix my libertyreserve api

Post by ck215631 »

libertyreserve.com api is update to v2.1 my site api is not work... somebody help me to fix it .... i will send $10 by paypal or payza for thanks ....
SKype:ck215631
following function is for transfer money.... is not work...i think $authString got some problem here ...it always return 200Authentication error...
by the guide of libertyreserve api

http://www.libertyreserve.com/en/help/apiguide
200 Authentication error This error is a result of incorrect secret API word, name of API or incorrect hash string for authentication token.

my api password and name .... dont have problem ... i think its must be incorrect hash string for authentication token...
please help me to fix it....

Code: Select all

<?

$send_to_lr('UXXXXX','Uyyyyyy','10.00','Meno','apipPassword','apiName');

 function send_to_lr ($tolr, $payer,$amount, $memo,$pwd,$api)
  {
    if (function_exists ('curl_init'))
    {
     
      $datePart = gmdate("Ymd");
      $timePart = gmdate("H");

	  $randID=time().rand(0,9999);
	  $usd="usd";
	  $ref="Reference";
     //$authString = $pwd.":".$datePart.":".$timePart;
	  $authString = $pwd.":".$randID.":".$ref.":".$tolr.":".$usd.":".$amount.":".$datePart.":".$timePart;
      $sha256 = strtoupper(bin2hex(mhash(MHASH_SHA256, $authString)));

$toXml = '<TransferRequest id="'.$randID.'">
<Auth><AccountId>'.$payer.'</AccountId><ApiName>'.$api.'</ApiName><Token>'.$sha256.'</Token></Auth>
<Transfer>
  <TransferType>transfer</TransferType>
  <PaymentPurpose>service</PaymentPurpose>
  <Payee>'.$tolr.'</Payee>
  <CurrencyId>usd</CurrencyId>
  <Amount>'.$amount.'</Amount>
  <Memo>'.$memo.'</Memo>
  <Anonymous>false</Anonymous>
</Transfer>
  </TransferRequest>';

$url = 'https://api2.libertyreserve.com/xml/transfer';
 $agents[] = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_6; en-us) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1";
      $ch = curl_init ();
      curl_setopt ($ch, CURLOPT_URL, $url);
	  curl_setopt($ch, CURLOPT_HEADER, 0);

      curl_setopt ($ch, CURLOPT_POSTFIELDS, 'req='.urlencode($toXml));
	  curl_setopt($ch, CURLOPT_USERAGENT, $agents[rand(0, (count($agents) - 1))]);

      curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
     // curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
	  curl_setopt ($ch, CURLOPT_POST, 1);

      $content = curl_exec ($ch);
      curl_close ($ch);
		  $parts = array ();
	//print_r($parts);
	
		  if (preg_match ('/<Receipt><ReceiptId>(\d+)/ims', $content, $parts))
		  {
			return array($parts[1]);
		  }

    }
    else
    {
      return 0;
    }
  }
  
		

?>
Post Reply