When making a REST API call, can you include the Authorization key in the url, like in a GET request?

StackOverflow https://stackoverflow.com/questions/11362702

質問

More specifically, I am looking at the Web Services of Commission Junction (http://help.cj.com/en/web_services/web_services.htm#Commission_Detail_Service.htm) and the Authorization key is supposed to be part of the "Header" for the request.

Would I be able to send the request with just a url? For example (using the URI from their website): https://publisher-lookup.api.cj.com/v2/joined-publisher-lookup?Authorization=[developer key]&url=http%3A%2F%2Fwww.cj.com

Also, if anybody is familiar with Pentaho Data Integration v4.3 (PDI or Kettle), help with making this API call using PDI would be much appreciated (that is ultimately what I am trying to achieve).

Thank you!

役に立ちましたか?

解決

For Firefox, there is an add-on to make a REST API call with headers: https://addons.mozilla.org/en-US/firefox/addon/modify-headers/

And Commission Junction outlines how to use it: http://www.cj.com/webservices/quick-start-guide

他のヒント

This depends 100% on commission junction since they'll be expecting the key in one place or another. They may have allowed for the means to pass it in the URL or not but it's implementation on their side which determines this and should be in their docs. Is doesn't invalidate the REST pattern per-se.

Sounds like you found out how to pass the params in the header anyway - so that's probably the way to go.

you should send the developer key as http header. Here is an example code for commissionjunction (CJ) in PHP:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://commission-detail.api.cj.com/v3/commissions?date-type=posting&start-date=" . date('Y-m-d', (time()-(24*3600))) . "&end-date=" . date('Y-m-d'));
curl_setopt($ch, CURLOPT_HEADER, false); 
curl_setopt($ch, CURLOPT_GET, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("authorization: " . $yourdeveloperkey));
$result = curl_exec($ch);
curl_close($ch);
print_r($result);
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top