Jump to content

Recommended Posts

I have a company that needs php tweaking. (My previous programmer couldn't be found anymore)

The client e-mailed me this

"Basically what we need is for you to provide us with an http rest API where we will provide the tracking code and in return you will return to us a JSON object with the status of the delivery

 

As an example:

 

TRACKING CODE: ABCDEFGHIJ

URL:

METHOD: GET

RESPONSE: {"status":2}

 

where 2 is the code for the status shipment which is defined by

 

1 - GOOD

2 - BETTER

3 - BEST"

How and where do I place this? What's "HTTP REST API" and "return to us a JSON object"

 

It's all gibberish to me! Some web guru answer me pls?:)

 

 

 

Thanks in advance!

Link to comment
https://forums.phpfreaks.com/topic/269895-http-rest-api-help/
Share on other sites

Just setup a script that gets a code, checks it and echoes out the status of it.

 

<?php


/**
* http://fastrak.com/track.php?code=ABCDEFGHIJ
*/


// get the CODE from the GET varaible
$code = isset($_GET["code"]) ? $_GET["code"] : "";


// to whatever you need to do to check if that $code is valid
// if its not valid return an 404 error


// then get the status of that code


$return = array(
   "status" => "get this status from the database or whatever",
);


// and echo that out
echo json_encode($return);


?>

Link to comment
https://forums.phpfreaks.com/topic/269895-http-rest-api-help/#findComment-1388101
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.