Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

Sorry, you do not have permission to ask a question, You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please type your username.

Please type your E-Mail.

Please choose an appropriate title for the post.

Please choose the appropriate section so your post can be easily searched.

Please choose suitable Keywords Ex: post, video.

Browse

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Navigation

  • Home
  • About Us
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • About Us
  • Contact Us
Home/ Questions/Q 1396

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Latest Questions

Author
  • 62k
Author
Asked: November 25, 20242024-11-25T07:47:07+00:00 2024-11-25T07:47:07+00:00

Free Carrier Auto-detection API for eCommerce – java demo

  • 62k

Carrier Auto-detection

You can submit the courier tracking number through this API to determine the carrier ID to which the tracking number may belong. The returned data is a list of possible carrier IDs, and the carrier ID with high possibility ranks first.

Reminder: The tracking number of each carrier is constantly changing, and there is no standardized rule for tracking number naming. We cannot guarantee that the returned result is 100 percent accurate. Our existing mechanism uses our accumulated data to analyze each carrier’s tracking number naming rule and update the rules daily.

We will not provide legal commitments on the accuracy and validity of the returned result. If you provide this service to your users, it is recommended that you should use the following reminders when giving the tracking result to your users:

  • Add a description such as “Possible Results” or “Possible Results Powered by KeyDelivery” or “This Result Is for Reference Only.”

  • The user can manually modify the carrier.

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.URL; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException;   /**  * Carrier Auto-detection  *  * @author https://www.kd100.com/  *  */ public class CarrierAutoDetection {      private static final String URL = "https://www.kd100.com/api/v1/carriers/detect";     //You can find your ApiKey on https://app.kd100.com/api-managment     private static final String API_KEY = "";     //You can find your Secret on https://app.kd100.com/api-managment     private static final String SECRET = "";     private static final int CONNECT_TIMEOUT = 1000;     private static final int READ_TIMEOUT = 5000;      public static void main(String[] args) {         String tracking_number = "9926933413";          CarrierAutoDetection demo = new CarrierAutoDetection();         String result = demo.getData(tracking_number);         System.out.println(result);     }        public String getData(String tracking_number) {          String param = "{"tracking_number": "" + tracking_number + ""}";          String signature = MD5Utils.encode(param + API_KEY + SECRET);         return this.post(param,signature);     }       public String post(String param,String signature) {         StringBuffer response = new StringBuffer("");          byte[] data = param.getBytes();          BufferedReader reader = null;         OutputStream out = null;         try {              URL url = new URL(URL);             HttpURLConnection conn = (HttpURLConnection) url.openConnection();             conn.setConnectTimeout(CONNECT_TIMEOUT);             conn.setReadTimeout(READ_TIMEOUT);             conn.setRequestMethod("POST");             conn.setRequestProperty("accept", "*/*");             conn.setRequestProperty("connection", "Keep-Alive");             conn.setRequestProperty("Content-Type", "application/json");             conn.setRequestProperty("Content-Length", String.valueOf(data.length));             conn.setRequestProperty("API-Key",API_KEY);             conn.setRequestProperty("signature",signature);             conn.setDoOutput(true);              out = conn.getOutputStream();             out.write(data);              reader = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));              String line = "";             while ((line = reader.readLine()) != null) {                 response.append(line);             }         } catch (Exception e) {             e.printStackTrace();         } finally {             try {                 if (null != out){                     out.flush();                     out.close();                 }                 if (null != reader) {                     reader.close();                 }             } catch (IOException e) {                 e.printStackTrace();             }         }          return response.toString();     } }   class MD5Utils {     private static MessageDigest mdigest = null;     private static char digits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};      private static MessageDigest getMdInst() {         if (null == mdigest) {             try {                 mdigest = MessageDigest.getInstance("MD5");             } catch (NoSuchAlgorithmException e) {                 e.printStackTrace();             }         }         return mdigest;     }      public static String encode(String s) {         if(null == s) {             return "";         }          try {             byte[] bytes = s.getBytes();             getMdInst().update(bytes);             byte[] md = getMdInst().digest();             int j = md.length;             char str[] = new char[j * 2];             int k = 0;             for (int i = 0; i < j; i++) {                 byte byte0 = md[i];                 str[k++] = digits[byte0 >>> 4 & 0xf];                 str[k++] = digits[byte0 & 0xf];             }             return new String(str);         } catch (Exception e) {             e.printStackTrace();             return null;         }     } } 
Enter fullscreen mode Exit fullscreen mode

javaprogrammingtutorialwebdev
  • 0 0 Answers
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Ask A Question

Stats

  • Questions 4k
  • Answers 0
  • Best Answers 0
  • Users 2k
  • Popular
  • Answers
  • Author

    Insights into Forms in Flask

    • 0 Answers
  • Author

    Kick Start Your Next Project With Holo Theme

    • 0 Answers
  • Author

    Refactoring for Efficiency: Tackling Performance Issues in Data-Heavy Pages

    • 0 Answers

Top Members

Samantha Carter

Samantha Carter

  • 0 Questions
  • 20 Points
Begginer
Ella Lewis

Ella Lewis

  • 0 Questions
  • 20 Points
Begginer
Isaac Anderson

Isaac Anderson

  • 0 Questions
  • 20 Points
Begginer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help

Footer

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore, ask, and connect. Join our vibrant Q&A community today!

About Us

  • About Us
  • Contact Us
  • All Users

Legal Stuff

  • Terms of Use
  • Privacy Policy
  • Cookie Policy

Help

  • Knowledge Base
  • Support

Follow

© 2022 Querify Question. All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.