Example API V1.1 - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of Example API V1.1.php

  1. <?php
  2. $api_key = '52172CF0F25851F62F089B763CBA6B12901FF90A';
  3. $secret_key = '9AF0EEE8642E9CFD4978D684628DE340C3D9E82A';
  4. //Check TransportFee
  5. $parameters = array(
  6.     'api_key' => $api_key,
  7.     'timestamp' => time(),
  8.     'data' => array(
  9.         'pickup_address_code' => 'VN034018001',
  10.         'receive_address_code' => 'VN034018002',
  11.         'service' => 'EE1',
  12.         'cod_value' => 50000,
  13.         'weight' =>1
  14.     )
  15. );
  16. //Create Authorization code
  17. $authorization = hash_hmac('sha1','SPEEDLINK', json_encode($parameters).$secret_key);
  18. echo 'CheckFee: <br>';
  19. echo 'Authorization: '.$authorization.'</br>';
  20. echo 'Parameter: </br>';
  21. echo json_encode($parameters);
  22. echo '<hr><br>';
  23. // Create Order
  24. $parameters = array(
  25.     'timestamp' => time(),
  26.     'api_key' => $api_key,
  27.     'data' => array(
  28.         'order_no' => 'ICTTEST124',
  29.         'order_note' => '',
  30.         'pickup_address' => '25 Ngô Quyền, Phường 6, Quận 10, TP.Hồ Chí Minh',
  31.         'pickup_address_code' => 'VN039007006',
  32.         'shipper_name' => 'Unica.vn',
  33.         'shipper_phone' => '0932776665',
  34.         'receiver_address' => '66/20 Hùng Vương, Phường 1, Quận 10, Thành phố Hồ Chí Minh',
  35.         'receiver_address_code' => 'VN034018009',
  36.         'receiver_name' => 'Võ Tấn Lực',
  37.         'receiver_phone' => '0905833933',
  38.         'weight' => 5,
  39.         'service_code' => 'TC1',
  40.         'payment_method' => 1,
  41.         'payer' => 1,
  42.         'cash' => 349000,
  43.         'cod_value' => 349000
  44.     )
  45. );
  46. //Create Authorization code
  47. $authorization = hash_hmac('sha1','SPEEDLINK', json_encode($parameters).$secret_key);
  48. echo 'Create Order: <br>';
  49. echo 'Authorization: '.$authorization.'</br>';
  50. echo 'Parameter: </br>';
  51. echo json_encode($parameters);
  52. echo '<hr><br>';
  53. // Tracking
  54. $parameters = array(
  55.     'timestamp' => time(),
  56.     'api_key' => $api_key,
  57.     'order_no' => 'ICTTEST124'
  58. );
  59. //Create Authorization code
  60. $authorization = hash_hmac('sha1','SPEEDLINK', json_encode($parameters).$secret_key);
  61. echo 'Tracking: <br>';
  62. echo 'Authorization: '.$authorization.'</br>';
  63. echo 'Parameter: </br>';
  64. echo json_encode($parameters);
  65. echo '<hr><br>';
  66.  
  67. ///Cancel Order
  68. $parameters = array(
  69.     'timestamp' => time(),
  70.     'api_key' => $api_key,
  71.     'order_no' => 'ICTTEST124'
  72. );
  73. //Create Authorization code
  74. $authorization = hash_hmac('sha1','SPEEDLINK', json_encode($parameters).$secret_key);
  75. echo 'Cancel: <br>';
  76. echo 'Authorization: '.$authorization.'</br>';
  77. echo 'Parameter: </br>';
  78. echo json_encode($parameters);
  79.  
  80.  
  81.  
File Description
  • Example API V1.1
  • PHP Code
  • 19 Aug-2019
  • 2.44 Kb
You can Share it: