DPD Label Printing using the PHP API for a Citizen label printer
<p>Any help would be appreciated. We are trying to connect a php system to automatically print DPD labels to a Citizen label printer. We are exploring using php_printer which is installed fine and can see the printer from our code, and the DPD api call is generating new shipments successfully on the DPD website.</p>

<p><strong>Questions</strong></p>

<ol>
<li>Firstly, is this the best way to go to send raw print data to a Citizen label printer from a PHP application using php_printer or is there a better way?</li>
<li>Secondly, we will be doing some live tests shortly, but there seems to be a formatting issue on the DPD api get Label call where we retrieve the raw citizen print data to send to the printer directly to trigger the print.</li>
</ol>

<p><strong>Expected Data from the API example</strong></p>

<pre><code>\M3000\c0000\e\O0220\f290\n\a\LD11PISIH12
2911A0803340387DPD
2911A0603500375www.dpd.co.uk
1911A1003800095Responsible Delivery - CO Neutral
1911A08037802572
2911A0603780354Sender
2911A0603780346GEOPOSTUK LTD
2911A0603780338ROEBUCK LANE
2911A0603780330SMETHWICK
2911A0603780322BIRMINGHAM
------ etc
</code></pre>

<p>We are receiving the data sample below in our output .txt file in that the slashes are not appearing in the file after file_put_contents and in our readers they either appear as spaces or black circles.</p>

<p><strong>Actual Data we are receiving</strong></p>

<pre><code>M3000c0000eO0220f290naLD11PISIH12
2911A0803340387DPD
2911A0603500375www.dpd.co.uk
1911A1003800095Responsible Delivery - CO   Neutral
1911A08037802572
2911A0603780354Sender
2911A0603780346GEOPOSTUK LTD
2911A0603780338ROEBUCK LANE
2911A0603780330SMETHWICK
2911A0603780322BIRMINGHAM
</code></pre>

<p>Can anyone suggest php headers or output settings that we need to configure to ensure nothing is being removed from the request?</p>

<p><strong>PHP code sample sent to DPD for the Label:-</strong></p>

<pre><code>$shipmentId = 123456789;
$method = '/shipping/shipment/' . $shipmentId . '/label/';

$url = 'https://api.dpd.co.uk . $method;
$options = array(
'http' =&gt; array(
    'method' =&gt; 'GET',
    'Host' =&gt; 'api.dpd.co.uk',
    //'header' =&gt; "Accept: text/html\r\n" .
    'header' =&gt; "Accept: text/vnd.citizen-clp" .
    "GEOClient: account/" . $account_number . "\r\n" .
    "GEOSession: " . $session . "\r\n"
 )
);

$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
file_put_contents("dpd_test_citizen_clp.txt", $result);
</code></pre>

<p>Thanks in advance!</p>