Jump to content

Error with CURLOPT_POSTFIELDS


Shiftoii

Recommended Posts


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.

Link to comment
https://forums.phpfreaks.com/topic/291097-error-with-curlopt_postfields/
Share on other sites

you had a  Syntax error there was no closing paren ) to the cookies part of the code here is the corrected  line below :happy-04:

curl_setopt ($ch, CURLOPT_COOKIE,"Användar Cookies Go Here");

if you continue receiving errors please paste the error below.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.