Advertisement
Guest User

vk-unclickable-avatar

a guest
Dec 4th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 1.66 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "os"
  5.     "flag"
  6.     "fmt"
  7.     "github.com/go-resty/resty"
  8.     "encoding/json"
  9.     //"errors"
  10.     "time"
  11.     //"strconv"
  12. )
  13. var token string
  14. type RequestParams map[string]string
  15. func main() {
  16.     flag.Parse()
  17.     args := flag.Args()
  18.     if len(args) < 1 {
  19.         fmt.Println("Usage: ./vk <token>")
  20.         os.Exit(1)
  21.     }
  22.     token = args[0]
  23.     params := make(RequestParams, 300)
  24.     params["album_id"] = "profile"
  25.     resp, err := CallMethod("photos.get", params)
  26.     if err != nil {
  27.         fmt.Println("ERROR")
  28.         os.Exit(1)
  29.     }
  30.     type JSONBody struct {
  31.         Response struct {
  32.             Count int `json:"count"`
  33.                 Items []struct {
  34.                         PhotoID int `json:"id"`
  35.                 } `json:"items"`
  36.         } `json:"response"`
  37.     }
  38.     var body JSONBody
  39.     json.Unmarshal(resp, &body);
  40.     if len(body.Response.Items) == 0  {
  41.         fmt.Println("PhotoID: undefined")
  42.         os.Exit(1)
  43.     }
  44.     msg := fmt.Sprintf("%d", body.Response.Items[0].PhotoID)
  45.     fmt.Println(msg)
  46.     for i := 0; i < 100; i++ {
  47.         params["photo_id"] = msg
  48.         _, err := CallMethod("photos.delete", params)
  49.         if err != nil {
  50.             fmt.Println("ERROR photos.delete")
  51.         }
  52.         _, err1 := CallMethod("photos.restore", params)
  53.         if err1 != nil {
  54.             fmt.Println("ERROR photos.restore")
  55.         }
  56.         fmt.Println("Avatar must not clickable!")
  57.         time.Sleep(100)
  58.     }
  59. }
  60. func CallMethod(method string, params RequestParams) ([]byte, error) {
  61.     params["access_token"] = token
  62.     params["lang"] = "ru" // or..
  63.     params["v"] = "5.60"
  64.  
  65.     resp, _ := resty.R().
  66.         SetQueryParams(params).
  67.         Get("https://api.vk.com/method/" + method)
  68.  
  69.     type JSONBody struct {
  70.         Error map[string]interface{} `json:"error"`
  71.     }
  72.  
  73.     var body JSONBody
  74.  
  75.     json.Unmarshal(resp.Body(), &body);
  76.  
  77.     return resp.Body(), nil
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement