Jump to content

Recommended Posts

Been working awhile on getting this completed with no luck
I have this script that is suppose to purchase items through cookies

<?php 




   $ch = curl_init(); 
   curl_setopt($ch, CURLOPT_HEADER, true); 
   curl_setopt($ch, CURLOPT_NOBODY, true); 
   curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); 
   curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); 
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); 




   curl_setopt($ch, CURLOPT_URL, ""); 
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
   curl_setopt($ch, CURLOPT_POST, true); 
   curl_setopt($ch, CURLOPT_TIMEOUT, 5); 
   curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0"); 




   $data = array( 
   'creator'   => '1', 
   'storeId'   => '123', 
   'items' => '{id:123,species:stud,at:keepsake}', 
   'pType' => '0' 
   ); 




   $cookies = array( 
   //Purchase cookie Goes here 
    'anx'           => '', 
    'anxs'           => '', 
    'JSESSIONID'            => '', 
    'dcDirtyCookie'           => '', 
    'user_num'           => '', 
    'user_nme'           => '', 
    'user_info'           => '', 
    'qinfo'           => '' 
    ); 




   curl_setopt($ch, CURLOPT_COOKIE, $cookies); 




   curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); 
   curl_setopt($ch, CURLOPT_POST, 1); 
   curl_setopt($ch, CURLOPT_POSTFIELDS, $data); 




   $output = curl_exec($ch); 
   curl_close($ch); 
   die($output); 
   $xml = simplexml_load_string($output); 
   print_r($xml,1); 
   echo("done\n"); 
   echo($output); 
   ?>

But..
Instead of it purchasing items with the script provided above and me having my cookies in there it just echo's them back out and onto the page, I would like for it to send the request to the requested url and purchase the item within the $data function.

Link to comment
https://forums.phpfreaks.com/topic/291101-curl-purchasing-items-with-cookies/
Share on other sites

I think you need to quote the keys and string values in your json array

 


$data = array( 
   
'creator'   => '1', 
   
'storeId'   => '123', 
  
'items' => '{id:123,species:stud,at:keepsake}',
   'pType' => '0' 
   
);

 

Try

  'items' => '{"id":123,"species":"stud","at":"keepsake"}', 
Edited by Barand
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.