Skip to content

Instantly share code, notes, and snippets.

@vdurmont
Last active August 29, 2015 14:06
Show Gist options
  • Save vdurmont/5386285b95a45860d65f to your computer and use it in GitHub Desktop.
Save vdurmont/5386285b95a45860d65f to your computer and use it in GitHub Desktop.
How to use JSONP with userinfo.io API
<!DOCTYPE html>
<html lang="en">
<head>
<title>UserInfo.io — JSONP callback</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript">
function userinfoCallback(data) {
console.log("I can now do awesome things with this beautiful data I just received!");
console.dir(data);
}
</script>
<script type="text/javascript" src="https://api.userinfo.io/userinfos?jsonp_callback=userinfoCallback"></script>
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<title>UserInfo.io — JSONP variable</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript" src="https://api.userinfo.io/userinfos?jsonp_variable=data"></script>
<script type="text/javascript">
console.log("Hey, that's awesome! I got a variable with the data!")
console.dir(data);
</script>
</head>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment