Skip to content

Instantly share code, notes, and snippets.

@rkotov93
Created January 26, 2012 23:45
Show Gist options
  • Save rkotov93/1685891 to your computer and use it in GitHub Desktop.
Save rkotov93/1685891 to your computer and use it in GitHub Desktop.
JS.VK.Example
<!-- http://vk.com/pages.php?o=-1&p=VK.Auth -->
<html>
<head>
<script src="http://vkontakte.ru/js/api/openapi.js" type="text/javascript"></script>
</head>
<body>
<div id="login_button" onclick="VK.Auth.login(authorize);"></div>
<script language="javascript">
VK.init({
apiId: 2773692
});
function authorize(response) {
if (response.session) {
alert("Authorization denied");
}
else {
alert("Authorization doen't denied");
}
}
VK.Api.call('friends.get', {fields: 'uid,first_name'}, function(data) {
alert(data.response.length);
if (data.error) {
alert(data.error.error_msg);
} else {
if (data.response.length > 0) {
for (i = 0; i < data.response.length; i++) {
alert(data.response[i]);
document.write("<p>" + data.response[i] + "</p>");
}
}
}
});
VK.UI.button('login_button');
</script>
</body>
</html>
@rasoulanari
Copy link

<script src="http://vkontakte.ru/js/api/openapi.js" type="text/javascript"></script>
<script language="javascript"> VK.init({ apiId: 2773692 }); function authorize(response) { if (response.session) { alert("Authorization denied"); } else { alert("Authorization doen't denied"); } }
  VK.Api.call('friends.get', {fields: 'uid,first_name'}, function(data) {
    alert(data.response.length);
    if (data.error) {
      alert(data.error.error_msg);
    } else {
      if (data.response.length > 0) {
        for (i = 0; i < data.response.length; i++) {
          alert(data.response[i]);
          document.write("<p>" + data.response[i] + "</p>");
        }
      }
    }
  });
  VK.UI.button('login_button');    
</script>

@trytocatcharg
Copy link

Do you know how to get the email with VK API?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment