1

I am trying to use the following the code to grab the balance in a gift card without using the walmart for enduser.

<?php 
$url = "https://www.walmart.com/cservice/ProcessShoppingCard.do";
//
$h = curl_init();

curl_setopt($h, CURLOPT_URL, $url); 
curl_setopt($h, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($h, CURLOPT_POST, true);
curl_setopt($h, CURLOPT_POSTFIELDS, array(
'cardNumber' => '1234567890123456',
'pin' => '1234',
'GetCardBalance' => 'GetCardBalance'
));
curl_setopt($h, CURLOPT_HEADER, true);
curl_setopt($h, CURLOPT_RETURNTRANSFER, true);

$result = curl_exec($h);
echo $result;


?>

But it seems to only show the page and not the results. I examined the form used in walmart and it has only 3 fields: cardNumber, pin and GetCardBalance.

Which i have used but still not getting the results.

If i go to this url https://www.walmart.com/cservice/ProcessShoppingCard.do And try to check the balance, it does show the response.

Any ideas, what and where i am doing wrong?

Please advice, thanks!

Aamir Siddique
  • 334
  • 3
  • 15
  • 3
    that's because you're fetching a url whose output is intended for human consumption. unless walmart provides a url which returns ONLY the balance, you'll have to use DOM operations to extract the balance from that "for humans only" html page. – Marc B Nov 14 '12 at 15:52
  • Are you logged in to the site? Even if not it might be using session variables in addition to the form. – tedders Nov 14 '12 at 15:53
  • 1
    Try the mobile-website. They serve static versions, as opposed to the dynamic content served by full-webpages. – Anirudh Ramanathan Nov 14 '12 at 15:55
  • This isn't going to work unless you can figure out exactly how that form is being submitted. The "submit" button isn't really a submit button at all, it is an input element and it is relying on javascript for the form to be really submitted. – Patrick James McDougle Nov 14 '12 at 16:01

1 Answers1

0

Ok, after lots of tries, i finally got able to use the following code to work. I was not using POSTFIELDS method properly. And i used Firefox Firebug to see what variables are being sent when submitting a form and used them according and it all worked :)

$url = "https://www.walmart.com/cservice/ProcessShoppingCard.do";
//
$h = curl_init();
curl_setopt($h, CURLOPT_URL, $url); 
curl_setopt($h, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($h, CURLOPT_POST, true);
curl_setopt($h, CURLOPT_POSTFIELDS, "cardNumber=1234567890123456&pin=1234&GetCardBalance.x=90&GetCardBalance.y=8");
curl_setopt($h, CURLOPT_HEADER, true);
curl_setopt($h, CURLOPT_RETURNTRANSFER, true);
//
$result = curl_exec($h);
echo $result;

Thank you all for your help and suggestions.

Aamir Siddique
  • 334
  • 3
  • 15