Published on 05/16/2021
Published by amit
Calling API in Awesome Enterprise
This sample just shows you how to do HTTP AUTH in the awesome enterprise
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
[php.base64_encode p1="easyee:IzTzi" o.set='template.base64pass' /] [template.set_array opts] [http] [method]GET[/method] [header]Authorization: Basic [env.get template.base64pass /][/header] [/http] [/template.set_array] [php.stream_context_create p1={template.opts} o.set='template.context' /] [env.echo template.opts /] [template.set pass='ABhiD6G2afffffK5gy#dN' /] [php.file_get_contents p1='https:/wordpoets.com/plot/modules/api?username=xyz&password={{template.get pass m.url_encode=yes}}&force_single_access=yes' p2=0 p3={template.context} o.set='template.contents'/] [env.echo template.contents /] |
Here is another example of Calling Github API in PHP using file_get_contents.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
[template.set_array opts] [http] [method]GET[/method] [header]User-Agent: awxdocs[/header] [/http] [/template.set_array] [php.stream_context_create p1={template.opts} o.set='template.context' /] [env.echo template.opts /] [php.file_get_contents p1='https://api.github.com/repos/WPoets/communication-handler/releases/latest' p2=0 p3={template.context} o.set='template.contents' /] [env.echo template.contents /] |
Here are a few examples using curl.api.get and curl.api.post, for this you will need to install curl extra handler
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
[template.set url_two='https://wpoets.com/api' /] [arr.create o.set='template.data'] [username _value='' /] [password _value='' /] [force_single_access]yes[/force_single_access] [/arr.create] [arr.create o.set='template.proxy'] [host _value=''/] [port _value=''/] [user _value=''/] [password _value=''/] [/arr.create] [arr.create o.set='template.headers'] [header new] [key _value=''/] [val _value=''/] [/header] [/arr.create] [curl.api.get url='{template.url_one}' o.set='template.urlone' /] [curl.api.get url='{template.url_two}' data='{template.data}' o.set='template.urltwo' /] [curl.api.post url='{template.url_two}' data='{template.data}' header='{template.headers}' proxy='{template.proxy}' o.set='template.urltwo' /] |