Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void vk::account::login()
- {
- if (this->username != "" && this->password != "")
- {
- string fields = "grant_type=password&client_id=" + to_string(this->client_id) + "&client_secret=" + this->client_secret + "&username=" + this->username + "&password=" + this->password + "&scope=notify,friends,photos,audio,video,docs,notes,pages,status,offers,questions,wall,groups,messages,notifications,stats,ads,offline";
- string nwresp = vk::net::GetNWPOSTResponse("https://oauth.vk.com/token", fields);
- if (nwresp[0] == '{')
- {
- size_t pos = nwresp.find("access_token");
- if (pos != string::npos)
- {
- json::value val;
- parse(nwresp, val);
- this->a_t = val["access_token"].as<string>();
- }
- else throw string("vk::account::login error: Bad login.");
- }
- else throw string("vk::account::login error: No { symbol found; response not JSON object.");
- }
- else throw string("vk::account::login error: No login/password found.");
- }
- void vk::account::login(string username, string password)
- {
- if (username != "" && password != "")
- {
- string fields = "grant_type=password&client_id=" + to_string(this->client_id) + "&client_secret=" + this->client_secret + "&username=" + username + "&password=" + password + "&scope=notify,friends,photos,audio,video,docs,notes,pages,status,offers,questions,wall,groups,messages,notifications,stats,ads,offline";
- string nwresp = vk::net::GetNWPOSTResponse("https://oauth.vk.com/token", fields);
- if (nwresp[0] == '{')
- {
- size_t pos = nwresp.find("access_token");
- if (pos != string::npos)
- {
- json::value val;
- parse(nwresp, val);
- this->a_t = val["access_token"].as<string>();
- }
- else throw string("vk::account::login error: Bad login.");
- }
- else throw string("vk::account::login error: No { symbol found; response not JSON object.");
- }
- else throw string("vk::account::login error: No login/password found.");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement