Created
December 16, 2021 21:17
-
-
Save alanef/6b58ecb33cd11d1e14578b08dbc945c9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var date = Utilities.formatDate(new Date(), "GMT", "EEE, dd MMM yyyy HH:mm:ss Z"); | |
| var secret = xxxxxx; | |
| var public_key = yyyyyyyyyy; | |
| var developer_id = 'xxxx'; | |
| var plugin_id = 'yyyy'; | |
| var resource_url = '/v1/developers/' + developer_id + '/plugins/' + plugin_id + '/installs.json'; | |
| // var resource_url = '/v1/ping.json'; | |
| // var resource_url = '/v1/developers/1281.json'; | |
| var content_md5 = ''; | |
| var string_to_sign = | |
| 'GET' + "\n" + | |
| content_md5 + "\n" + | |
| "" + "\n" + | |
| date + "\n" + | |
| resource_url; | |
| var byteSignature = Utilities.computeHmacSha256Signature(string_to_sign, secret, Utilities.Charset.UTF_8 ); | |
| var signatureStr = byteToHexString (byteSignature); | |
| var str = Utilities.base64Encode( signatureStr, Utilities.Charset.UTF_8 ); | |
| var res = str.replace(/=/g,''); | |
| var auth = 'FS ' + developer_id + ':' + public_key + ':' + res ; | |
| var options = { | |
| headers: { | |
| "Content-MD5": content_md5, | |
| "Date": date, | |
| "Authorization": auth, | |
| "contentType": "application/json", | |
| "method": "GET" | |
| }, | |
| muteHttpExceptions: true | |
| }; | |
| var response = UrlFetchApp.fetch('https://api.freemius.com' + resource_url, options); | |
| // var response = UrlFetchApp.fetch('http://requestbin.fullcontact.com/r3xdx5r3', options); | |
| Logger.log(response.getContentText()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment