Support the ongoing development of Laravel.io →
Requests IOC

Hi all,

Im trying to make a function for creating a package label via something called pacsoft. It only accepts XML and the below code is take from a straight up php example.

The curl part should work as is - but how do i write the below xml in my controller so that it becomes $xml ?

 $ch = curl_init("https://www.pacsoftonline.com/ufoweb/order?user=".$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>
</pacsoftonline>
Last updated 3 years ago.
0

After advise on irc i did the following:

			$xml = '<?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>
			</pacsoftonline>
			';

and that worked :)

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

olebulow olebulow Joined 31 Jan 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.