basically I have been assigned to build a REST request application in PHP, using a 3rd party REST API. Doing POSTs, GETs etc seems simple, however they have something called an Authorization header which uses a Digest token. How do I pass this via a get?
EG:
$url = "http:/domain/core.xml";
$response = file_get_contents($url);
echo $response;
Returns : Digest auth headers not found
In FireFoxes POSTER i would simply add the header "Authorization" with the value "Digest 0:codehere" and it works.
It is a standard that guides the design and development of processes which enable us interact with data stored on a web servers. The above definition may not look as complex or "professional" as the ones you come across on the internet, but the goal here is for you to understand the basic purpose of REST APIs.
Easy to Learn and Implement REST uses HTTP methods for communication and most of us are familiar with the HTTP verbs such as GET, POST, PUT or DELETE. These methods are self-explanatory that what it does (in case if you don't know these terms) and that makes REST easy to learn.
See file_get_contents()
string file_get_contents ( string $filename [, bool $use_include_path = false [, resource $context [, int $offset = -1 [, int $maxlen ]]]] )
The third argument $context
allows you to add a context create by stream_context_create(). See HTTP context options. There you can find an option header
, that allows you to set headers to be used by the request you send, in your case the Authorization
-header
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With