2017-05-27 144 views
3

我正在玩VK API,並設置了一個應用程序,並安裝了我需要的所有東西。 然而,當我打電話account.GetProfiles方法對MZ輪廓,我收到以下錯誤信息:VK API java sdk account.getProfiles訪問被拒絕?

{"error":{"error_code":15,"error_msg":"Access denied: no access to call this method","request_params":[{"key":"oauth","value":"1"},{"key":"method","value":"account.getProfileInfo"},{"key":"uid","value":"430334214"}]}} 

我的代碼是查詢如下:

String getProfile = "https://api.vk.com/method/account.getProfileInfo?uid="+userID+"&access_token="+oauth2Token; 
    URL profile = new URL(getProfile); 
    HttpURLConnection connection = (HttpURLConnection) profile .openConnection(); 
    System.out.println("/#/Debug: "+profile .toString()); 
    connection.setRequestMethod("GET"); 
    int responseCode = connection.getResponseCode(); 

人有一個想法?不幸的是,網上沒有太多的英文...我一直在努力爭取一個多小時,試圖找出這一個... 如果我只是調用getProfiles方法,所有作品像魅力,但我想獲得更多的數據......

歡呼

回答

0

你需要獲得的服務訪問鍵進行查詢account.GetProfiles按照鏈接:

https://vk.com/dev 

選擇項目「我的應用」 - >「設置」並創建您的應用程序令牌。使用「服務令牌」將請求發送到VK API。

+0

不幸的是它不起作用。我將它作爲請求中的附加參數傳遞,同樣的錯誤消息仍然存在... –

+0

瞭解更多關於調用此方法的信息:https://vk.com/dev/account.getProfileInfo,它僅適用於獨立應用程序(移動)和只能通過隱式流。 –