User Tools

Site Tools


en:api_integracio

FOXPOST The smartest Parcels (Parcel Delivery System)

If you are using a customly programmed webshop you can do the followings from your system:

  • Request the locations
  • Send an order
  • Modify, replace, delete existing orders
  • Request the status of the parcels
  • Print a label

The API documentation:

There are two separated ways to request the locations for the developers.

  • PHP cURL request
          <?php
             $ch = curl_init("URL");

            curl_setopt($ch, CURLOPT_HEADER, 0);
            curl_setopt($ch,CURLOPT_HEADER,"Accept:application/vnd.cleveron+json; version=1.0");
            curl_setopt($ch,CURLOPT_HEADER,"Content-Type:application/vnd.cleveron+json");
            curl_setopt($ch,CURLOPT_USERPWD,"USERNAME:PASSWORD");
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);


            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
            $res =curl_exec($ch);
            $res=json_decode($res);
            curl_close($ch);
          ?> 
        
  • Request from a server (file_get_contents)

There are 3 easy way to send an order to our system.

  • With API request
        <?php
        
         $jt = array (              
            "place_id"=> "24",
            "name" => "xxx", 
            "phone" => "123456789", 
            "email" => "xxx@XX.hu",
            "comment" => "Teszt Rendelés",
            "refcode" => "XXX",
            "language" => "hu-HU",
            "cod_amount" => "10000",
            "cod_currency" => "HUF",
          );                       
          $string=json_encode($jt);
        

          $context = stream_context_create(array(
          'http' => array(
             'header' => 'Authorization: Basic ' . base64_encode(usernam:password) . "\r\n" .
             'Accept: application/vnd.cleveron+json; version=1.0' . "\r\n" .
             'Content-Type: application/vnd.cleveron+json; version=1.0' . "\r\n" .
             'Content-Length: ' . strlen($string) . "\r\n" .
             'Accept-Encoding: gzip, deflate',
             'method'=>'POST',
             'content' => $string
          )
        ));


        $data = file_get_contents(URL . 'orders', false, $context);

  
 
        ?>
    
  • BATCH import with CSV or XLS file format.
    • You can find a sample file in our e-service portal and use this file as sample to generate the bacth file from your webshop.
  • Manually send an order.
    • On the e-service portel click on the Add Order Button and fill the parameters.

You can only use theese resources if the order status is CREATE

<?php
	if (isset($_GET['operation'])) {

		$operation = strtoupper($_GET['operation']);
		$barcode = '';
		$json = '';
		if (isset($_GET['barcode'])) {
			$barcode = $_GET['barcode'];
		}
		if (isset($_GET['json'])) {
			$json = $_GET['json'];
		}
                
                //print $operation;
		
		$url = 'https://api.foxpost.hu/ecomm/orders/' . $barcode;

		$ch = curl_init($url);

		curl_setopt($ch,CURLOPT_USERPWD,'USERNAME:PASSWORD');

		if ($operation != 'DELETE' && $operation != 'GET') {
			curl_setopt($ch, CURLOPT_POST, true);
			curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
		}
		curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $operation);
		curl_setopt($ch, CURLOPT_HTTPHEADER, array(
			'Accept: application/vnd.cleveron+json; version=1.0',
			'Content-Type: application/vnd.cleveron+json; version=1.0')
		);

		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
		$res = curl_exec($ch);
		curl_close($ch);

		var_dump($res);		
	}
?>

   <?php
     $ch = curl_init("URL/BARCODE");
            //$fp = fopen("example_homepage.txt", "w");

            //curl_setopt($ch, CURLOPT_FILE, $fp);
            curl_setopt($ch, CURLOPT_HEADER, 0);
            curl_setopt($ch,CURLOPT_HEADER,"Accept:application/vnd.cleveron+json; version=1.0");
            curl_setopt($ch,CURLOPT_HEADER,"Content-Type:application/vnd.cleveron+xml");
            curl_setopt($ch,CURLOPT_USERPWD,"username:password");
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);


            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

            $res1 =curl_exec($ch);
            curl_close($ch);

            $res1=json_decode($res1);
            
          switch ($res1->status) {
               
             case "new": 
                 $a="New order";   
                break;
            case "to-term": 
                  $a="Parcel is on the way to logistics terminal" ; 
                break;
            case "in-term": 
                   $a="Parcel is in logistics terminal";
                break;
            case "to-apt": 
                   $a="Parcel is on the way to APT"; 
                break;
            case "in-apt": 
                   $a="Parcel is in APT";  
                break;
            case "delivered": 
                   $a="Delivered";  
                break;
            case "ret-in-apt": 
                  $a="Returned parcel is in APT";   
                break;
            case "ret-to-term": 
                   $a="Returned parcel is on the way to logistics terminal";  
                break;
            case "ret-in-term": 
                   $a="Returned parcel is in logistics terminal";  
                break;
            case "ret-to-apt": 
                    $a="Returned parcel is on the way to APT"; 
                break;
            case "ret-delivered": 
                    $a="Returned parcel is delivered to the customer"; 
                break;
            case "lost": 
                    $a="Parcel is lost"; 
                break;
            case "cancelled": 
                    $a="Order was cancelled"; 
                break;
            default: 
                    $a="Ez a rendelési szám nem található rendszerünkben";
                break;

            } 
            
            print $a;
         }
     ?>
  

???Print a label !!!You have 2 opportunities to print a label at our E-service portal.

  • Multiple labels at A4 size or 8 piece / A4
    • After the parcel selection you can choose this 2 options
  • If you are printing 1 label the 1 / A4 size only avaiable

IMPORTANT

We are recommend to use the adobe reader for downloded pdf documentsAdobe Reader.

en/api_integracio.txt · Last modified: 2015/07/28 13:52 by roland