Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Vkontakte (vk.com) REST API client for mobile/desktop apps.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 src
Octocat-spinner-32 .gitignore
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.md
README.md

VkRestClient

This is a Vkontakte (http://vk.com) REST API client that I was using for a WP7 project. The API is incomplete and is in kinda alpha/dead stage. But if you are actually going to use this, feel free to contact me and I'll try to be of as much help as possible.

Sample code

Basic usage looks like this:

// Authenticate
var authResponse = await VkApi.Methods.Auth.GetToken(
    'my_login', 'my_password',
    'my_app_id', 'my_app_key')
     .ExecuteFree();

// Check if authentication succeeded
if (!authResponse.IsSuccess) throw new Exception("Couldn't authenticate!");

// Create a session object
var userSession = new VkApiSession(
    @"http://api.vk.com",
    authResponse.Data);

// Get ten last messages
var getMessagesResponse = await VkApi.Methods.Messages.Get(10)
    .ExecuteIn(userSession);

// Check if everything's OK
if (!getMessagesResponse.IsSuccess) throw new Exception("Couldn't fetch messages!");

// Print them out!
Console.WriteLine("Your last 10 (at most) messages are:\n" + string.Join("\n", from m in getMessagesResponse.Data.Messages select m.Body));

Dependencies

I used RestSharp for HTTP transport and Newtonsoft JSON.NET to parse JSON. I also made some use of Async CTP, although the API itself is usable with plain continuation callbacks.

Precautions

The tests are integration-style and should cover almost all the code.

All basic stuff like authentication and sending/receiving messages works. What might not work as you expect (or not work at all) is the long polling.

License

I think the BSD license is suitable for this kind of software.

Something went wrong with that request. Please try again.