N
N
nepster-web2015-12-30 01:42:51
PHP
nepster-web, 2015-12-30 01:42:51

Is there a convenient library for working with the REST API?

Can you please tell me if there is a convenient library for organizing requests and receiving responses from the server with the rest api?
Interested in a ready-made wrapper for something like this:

// Set the url, number of GET vars, GET data
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POST, false);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );
        
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        
        // Execute request
        $result = curl_exec($ch);
        
        // Close connection
        curl_close($ch);
        
        // get the result and parse to JSON
        $responce = json_decode($result, true);

It is desirable to be able to select the request method and indicate the header to receive json data.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Aksentiev, 2015-12-30
@nepster-web

Wrap your code in a function and you will have a library for working with the rest api.
And in general, it googles on request php rest client, it already depends on your taste, what you like more

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question