1

Say I perform a curl request to get some json back for teams within my api. e.g

curl -H "Content-type: application/json" -H "Authorization: Token token=xxxxxxxxxxxxxxxxxxxxxxx" -X GET -G     --data-urlencode "limit=100"    --data-urlencode "offset=0"   "https://my.api.com/teams"

Is there anyway I can turn this into a script within some html to be run and display my information back on demand?

I was thinking an input box Team Name where the user enters what team they want and the script runs adding a variable ?team=

I am new to APIs so if what I am thinking of is totally wrong I apologise in advance

1 Answer 1

2

If you are familiar with PHP, you can use the PHP cURL library to make the same request and then output the response as HTML. Something like:

<html>
<body>
<?php
$ch = curl_init("https://my.api.com/teams?getKey1=getValue1&getKey2=getValue2");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Your_Header_1: value1',
    'Your_Header_2: value2'
));

$server_output = curl_exec($ch);
curl_close($ch);
print $server_output;
?>
</body>
</html>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.