Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kefir500/vk-api-angular

VK Open API and widgets AngularJS wrapper.
https://github.com/kefir500/vk-api-angular

angularjs api api-wrapper promise vk vk-api

Last synced: 2 months ago
JSON representation

VK Open API and widgets AngularJS wrapper.

Awesome Lists containing this project

README

        

# VK API Angular

[![Build Status](https://travis-ci.org/kefir500/vk-api-angular.svg)](https://travis-ci.org/kefir500/vk-api-angular)
[![Codecov](https://codecov.io/gh/kefir500/vk-api-angular/coverage.svg)](https://codecov.io/gh/kefir500/vk-api-angular)
[![devDependencies Status](https://david-dm.org/kefir500/vk-api-angular/dev-status.svg)](https://david-dm.org/kefir500/vk-api-angular?type=dev)

VK Open API wrapper for AngularJS.

- Supports [VK API methods](https://vk.com/dev/methods) via AngularJS service.
- Supports [VK widgets](https://vk.com/dev/sites) via AngularJS directives.
- Replaces callbacks with promises.

[Docs & Demo](https://kefir500.github.io/vk-api-angular/)

## VK API (service)

You may **initialize** your VK application using the provider during the configuration phase:

```javascript
angular.module('my-app', ['vk-api-angular'])
.config(function (VKApiProvider) {
VKApiProvider.init(10000); // Your VK APP_ID
});
```

VKApi factory duplicates the official VK Open API method naming, in particular:

- `VKApi.Api.call`
- `VKApi.Auth.login`
- `VKApi.Auth.logout`
- `VKApi.Auth.revokeGrants`
- `VKApi.Auth.getLoginStatus`
- `VKApi.Auth.getSession`

However, the promises are used instead of callbacks. This gives a better control over the success/error handling mechanism.

- [Methods List](https://vk.com/dev/methods)
- [Permissions List](https://vk.com/dev/permissions)

```javascript
// Log in and request the "photos" and "video" permissions.
// See https://vk.com/dev/permissions for the full permission list.

VKApi.Auth.login({
photos: true,
video: true
}).then(
// Success:
function (response) {
var name = response.session.user.first_name;
alert('Hello, ' + name + '!');
},
// Error:
function (response) {
alert('Sorry, access denied.');
console.error(response);
}
);
```

```javascript
// Call "users.get" API method.
// See https://vk.com/dev/methods for the full method list.

VKApi.Api.call('users.get').then(
// Success:
function (response) {
var name = response[0].first_name;
alert('Hello, ' + name + '!');
},
// Error:
function (response) {
alert('Sorry, could not fetch the user data.');
console.error(response);
}
);
```

## VK Widgets (directives)

#### VK *Allow Messages From Community* Widget

```xml

```

#### VK *Auth* Widget

```xml

```

#### VK *Comments* Widget

```xml

```

#### VK *Community* Widget

```xml

```

#### VK *Community Messages* Widget

```xml

```

#### VK *Contact Us* Widget

```xml

```

#### VK *Like* Widget

```xml

```

#### VK *Poll* Widget

```xml

```

#### VK *Post* Widget

```xml

```

#### VK *Recommended* Widget

```xml

```

#### VK *Share* Widget

```xml

```

#### VK *Subscribe* Widget

```xml

```