Converting a curl+xml to laravel and guzzle



Ive been puzzling with this for days, and I will now give it a shot here.


Im using laravel 4 with the newest guzzle.


What i want to do is convert the below code to laravel+guzzle:



$ch = curl_init("http://ift.tt/1nbXTrU".$pacsoft_user."&pin=".$pacsoft_pass."&type=xml&session=po_DK");
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml'));
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);

<?xml version="1.0" encoding="UTF-8"?>
<pacsoftonline>
<receiver rcvid="">
<val n="name">-</val>
<val n="address1">-</val>
<val n="address2"></val>
<val n="zipcode">-</val>
<val n="city">-</val>
<val n="country">DK</val>
<val n="contact"></val>
<val n="email"></val>
<val n="sms"></val>
</receiver>

<receiver rcvid="1">
<val n="from"></val>
<val n="to">1</val>
<val n="name">Test ApS</val>
<val n="address1"></val>
<val n="address2"></val>
<val n="zipcode"></val>
<val n="city"></val>
<val n="country">DK</val>
<partner parid="">
<val n="custno"></val>
</partner>
</receiver>

</pacsoftonline>


I now that i can just use curl (and thats fine with me also) but how do i write the xml lines in my controller?


No comments:

Post a Comment