Shiftoii Posted September 16, 2014 Share Posted September 16, 2014 (edited) Alright so as my title says I am working on trying to use curl to store the cookies of an item at the moment and fill out everything as listed. <?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://www.example.com/purchased"); 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"); //objekt array $TStringError = array( 'storeId' => 'ID', 'items' => 'ID', 'pType' => 'PType' ); $cookies = array( //detta ar dina inkops cookies 'anx' => 'UniqueCookie' ); curl_setopt ($ch, CURLOPT_COOKIE, //begagnade cookies ga hit "Användar Cookies Go Here" curl_setopt($ch, CURLOPT_POSTFIELDS, $TStringError); $output = curl_exec($ch); curl_close($ch); $xml = simplexml_load_string($output); print_r($xml,1); echo("done\n"); echo($output); ?> I started messing with my code because of an XML error it was not sending properly and I still am not sure why I just randomly saved it again and I was getting a T String Error but if I was to remove any thing from the line that it's on it would just error out another error.. curl_setopt($ch, CURLOPT_POSTFIELDS, $TStringError); This is what's giving me the error.. and if anyone could help me to know why it's not process the cookies properly.. that would be amazing. Sorry for bad english. Edited September 16, 2014 by Shiftoii Quote Link to comment https://forums.phpfreaks.com/topic/291097-error-with-curlopt_postfields/ Share on other sites More sharing options...
darkfreaks Posted September 18, 2014 Share Posted September 18, 2014 you had a Syntax error there was no closing paren ) to the cookies part of the code here is the corrected line below curl_setopt ($ch, CURLOPT_COOKIE,"Användar Cookies Go Here"); if you continue receiving errors please paste the error below. Quote Link to comment https://forums.phpfreaks.com/topic/291097-error-with-curlopt_postfields/#findComment-1491560 Share on other sites More sharing options...
darkfreaks Posted September 19, 2014 Share Posted September 19, 2014 also print_r($xml, 1); // print_r does not accept an integer as boolean change to: print_r($xml, true); Quote Link to comment https://forums.phpfreaks.com/topic/291097-error-with-curlopt_postfields/#findComment-1491594 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.