I am using curl to put an update to an xml file which is made into an simpleXML object then I use asXML() before putting the file to curl.
I have a three function setup for this:
>>get with a curl (works fine)
>>process data with simpleXML (maybe causing problems)
>>putting info with curl (works fine when used on other simpleXML calls)
I should note that the get and put with curl functions are being reused and succeed in all other cases I use it.
I just one unique function for this particular simpleXML call which does the processing. I am currently getting a 400 error when I try to put with curl (this is the most info I have at this point)
Here is my unique simpleXML process function:
PHP Code:
function processData($result, $value)
{
$xml = new SimpleXMLElement($result);
$newXML = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<subscription xmlns="http://domain.com">
<status>'.$xml->status.'</status>
<data>'.$value.'</data>
<id>'.$xml->id.'</id>
<card>
<last-four>'.$xml->card->{"last-four"}.'</last-four>
<type>'.$xml->card->type.'</type>
</card>
<charge>
<currency>'.$xml->{"charge"}->currency.'</currency>
<amount>9.99</amount>
</charge>
<charge-frequency>'.$xml->{"charge-frequency"}.'</charge-frequency>
<date>'.$xml->date.'</date>
<auto-renew>'.$xml->{"auto-renew"}.'</auto-renew>
<last-charge-result>
<result-code>'.$xml->{"last-charge-result"}->{"result-code"}.'</result-code>
</last-charge-result>
</subscription>';
$newSimpleXML = new SimpleXMLElement($newXML);
$newSimpleXML->data = $value;
$newXML = $newSimpleXML->asXML();
echo '$value is: "'.$value.'"<br />';
echo 'new status is: '.$newSimpleXML->data.'<br />';
echo 'The data was: '.$xml->data;
return $newXML;
}
the $result is derived from the get curl function, I have checked the output it is getting all the info I need
I appreciate any help in the matter