PHP REST client API call

api, curl, json, php, rest

Solution

You can use `file_get_contents` if the fopen wrappers are enabled. See: http://php.net/manual/en/function.file-get-contents.php

If they are not, and you cannot fix that because your host doesn't allow it, `cURL` is a good method to use.

Problem

I'm wondering, is there an easy way to perform a REST API GET call? I've been reading about cURL, but is that a good way to do it? I also came across php://input but I have no idea how to use it. Does anyone have an example for me? I don't need advanced API client stuff, I just need to perform a GET call to a certain URL to get some JSON data that will be parsed by the client. Thanks!

Original source