D
D
dk-web2015-10-15 18:08:42
Laravel
dk-web, 2015-10-15 18:08:42

Can you help me understand the principles of working with the API of third-party resources?

There was, in fact, such a need. Conceptually, I think I understand how it works... But it's easier for me to understand when you see a ready-made, working, simple example...
Registered in a couple of places - mostly paid ones.. Somewhere http, post, get - then curl, rest , soap... with which I have never worked... to pass headers - in general, porridge (
I would be grateful if you give a resource - a lesson, a video lesson ... a ready-made package for laravel or just a php class, where it is clear how the request is formed for server and the data comes in.
UPD: so far I could only implement it through file_get_contents ..
It turned out well ...

$params = array(
            'carrier' => $carrier,
            'flight' => $flight,
            'year' => $arrival->format('Y'),
            'month' => $arrival->format('m'),
            'day' => $arrival->format('d'),
        );
        $apiCall = sprintf($this->apiUrl.'flight/status/%s/%s/arr/%d/%d/%d', $params['carrier'], $params['flight'], $params['year'], $params['month'], $params['day']);
        $apiCall.="?appId={$this->id}&appKey={$this->key}";
        $res=file_get_contents($apiCall);
        return json_decode($res);

I tried using the Guzzle Client... but so far it has not been possible to transfer data for authorization

Answer the question

In order to leave comments, you need to log in

4 answer(s)
K
KIN1991, 2015-10-15
@KIN1991

habrahabr.ru/post/150803

V
vildulv, 2015-10-15
@vildulv

Here, for example, api photolia - a well-known service. https://github.com/robywan/fotolia-api . Look how it's done. Everything seems to be simple.

A
Alexander Aksentiev, 2015-10-15
@Sanasol

First you need to learn the language in which you are going to write and understand how the Internet works in general.
And this question will no longer arise.
Without a clear goal, there is no clear HOW.
How to work with any api?
Somehow.

S
Sergey Romanov, 2015-10-15
@Serhioromano

Можете попробовать это
https://market.mashape.com/explore
Это репозитория публиыных API. Каждая имеет документацию, форму для проверки, примеры на разных языка.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question