Skip to content

Instantly share code, notes, and snippets.

@higarin
Last active March 18, 2020 01:49
Show Gist options
  • Save higarin/401741f8371b2e0c3f9944a4acb9ed92 to your computer and use it in GitHub Desktop.
Save higarin/401741f8371b2e0c3f9944a4acb9ed92 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="Hello, world!">
<Require feature="opensocial-0.8" />
</ModulePrefs>
<Content type="html">
<![CDATA[
<div>Token: <input type="text" id="token" /></div>
<div>Token: <input type="text" id="player" /></div>
<div>Token: <input type="text" id="connect" /></div>
<script type="text/javascript">
function makeReq() {
console.log('makeReq');
var url = 'http://environment.eba-erucyhyr.ap-northeast-1.elasticbeanstalk.com/oauth/signIn/mixi';
var params = {};
params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.POST;
params[gadgets.io.RequestParameters.POST_DATA] = gadgets.io.encodeValues({num: 123456789});
params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.JSON;
params[gadgets.io.RequestParameters.AUTHORIZATION] = gadgets.io.AuthorizationType.SIGNED;
gadgets.io.makeRequest(url, function(response) {
console.log('makeReq', response);
document.getElementById("token").value = response.data.token;
document.getElementById("player").value = response.data.playerId;
if (response.data.connected) {
document.getElementById("connect").value = response.data.connected.playerId;
}
}, params);
}
gadgets.util.registerOnLoadHandler(makeReq);
</script>
]]></Content>
</Module>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment