Answer the question
In order to leave comments, you need to log in
VK API - How to make it work, docs don't save (sig generation)?
Here is what I found from docks
1 and 2
Code that I have now
string login = ""; // Login
string pass = ""; // Pass
using (var request = new xNet.HttpRequest())
{
request.Cookies = new CookieDictionary();
request.AllowAutoRedirect = false;
request.UserAgent = "VKAndroidApp/4.10.0-1151 (Android 4.4.2; SDK 19; armeabi-v7a; LGE LGM-V300K; ru)";
request.AllowAutoRedirect = false;
request.IgnoreProtocolErrors = true;
string auth = request.Get("https://oauth.vk.com/token?scope=nohttps%2Call&client_id=2274003&client_secret=hHbZxrka2uZ6jB1inYsH&2fa_supported=1&lang=ru&device_id=&grant_type=password&username=" + login + "&password=" + pass + "&libverify_support=1").ToString();
File.AppendAllText("1.txt", auth);
if (auth.Contains("access_token"))
{
string access_token = Pars(auth, "access_token\":\"", "\"", 0);
string user_id = Pars(auth, "user_id\":", ",\"", 0);
string secret = Pars(auth, "secret\":\"", "\"", 0);
string sig = GetMd5Hash(MD5.Create(), "execute.getFriendsAndLists" + secret);
string friend_get = request.Get("https://api.vk.com/method/execute.getFriendsAndLists?access_token=" + access_token + "&sig=" + sig).ToString();
txtLog.Text = friend_get;
}
else if (auth.Contains("username_or_password_is_incorrect"))
{
MessageBox.Show("Bad");
}
else
{
MessageBox.Show("Error");
}
public static string GetMd5Hash(MD5 md5Hash, string input)
{
byte[] data = md5Hash.ComputeHash(Encoding.UTF8.GetBytes(input));
StringBuilder sBuilder = new StringBuilder();
for (int i = 0; i < data.Length; i++)
{
sBuilder.Append(data[i].ToString("x2"));
}
return sBuilder.ToString();
}
Answer the question
In order to leave comments, you need to log in
update
sig = md5("api_id={api_id}method=friends.getrandom={random}timestamp={timestamp}user_id={user_id}{app_secret}")
url = "https://api.vkontakte.ru/api.php?api_id={api_id}&method=friends.get&random={random}×tamp={timestamp}&sig={sig}&user_id={user_id}"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question