Android 在新图形请求中使用存储在字符串变量中的AccessToken

Android 在新图形请求中使用存储在字符串变量中的AccessToken,android,facebook-graph-api,Android,Facebook Graph Api,我是一个新手程序员,尝试使用graph API将照片发布到Facebook页面。但我需要页面访问令牌。我使用此函数将页面访问令牌存储到字符串变量中 AccessToken token=AccessToken.getCurrentAccessToken(); GraphRequest request = GraphRequest.newGraphPathRequest( token, "/me/accounts"

我是一个新手程序员,尝试使用graph API将照片发布到Facebook页面。但我需要页面访问令牌。我使用此函数将页面访问令牌存储到字符串变量中

  AccessToken token=AccessToken.getCurrentAccessToken();

        GraphRequest request = GraphRequest.newGraphPathRequest(
                token,
                "/me/accounts",
                new GraphRequest.Callback() {
                    @Override
                    public void onCompleted(GraphResponse response) {
                        // Insert your code here
                        try {

                            JSONObject res=new JSONObject(response.toString());

                            JSONArray data=res.getJSONArray("data");

                             accessToken = "";

                            for(int i=0;i<data.length();i++){

                                JSONObject temp=data.getJSONObject(i);

                                if(temp.has("access_token")){

                                    accessToken=temp.getString("access_token");

                                    break;

                                }

                            }

                        }catch (JSONException e)
                        {
                            e.printStackTrace();
                        }
                    }
                });

        request.executeAsync();
AccessToken-token=AccessToken.getCurrentAccessToken();
GraphRequest请求=GraphRequest.newGraphPathRequest(
代币
“/me/accounts”,
新建GraphRequest.Callback(){
@凌驾
未完成公共空白(图形响应){
//在这里插入您的代码
试一试{
JSONObject res=新的JSONObject(response.toString());
JSONArray data=res.getJSONArray(“数据”);
accessToken=“”;
对于(int i=0;i