A
A
Alexander Wolf2015-08-12 19:50:37
API
Alexander Wolf, 2015-08-12 19:50:37

Who can help write a very simple API?

Hello Toaster. I'll start from afar:
We wrote one program here - a webcam scanner. Searches, brute-forces, saves screenshots to a folder, generates result files as nmap.
Now there is a need to organize a system of keys, so that no outsider who does not have a key could use the program.
There was an idea to make everything quite simple - a file with keys lying on the program's website.
She would check with him and give the result.
But, you know, this is a so-so decision. In addition, all the source codes were on Github, which means that finding out where this file is located will not be a problem.
Then the idea arose to create a small API for these purposes. Only there is one problem - none of us have ever dealt with the API and have no idea how it's supposed to work.
Actually, can someone just write these couple of lines of code and explain how everything should work, or at least give a tip where to dig? Maybe some literature.
Thank you very much in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2015-08-12
@zkelo

The API must accept a request (POST / GET), process it and, in accordance with it, send back a response in xml, json or plain format.

M
Mr Freeman, 2015-08-12
@vladamir

I advise you to use Silex for api. It develops quickly and does not require much knowledge.

$app->get('/users/{id}', function ($id) use ($app) {
    $user = getUser($id);

    if (!$user) {
        $error = array('message' => 'The user was not found.');

        return $app->json($error, 404);
    }

    return $app->json($user);
});

Here is an example from their documentation that shows how easy it is to send/receive data

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question