当前位置: 首页>>代码示例>>Java>>正文


Java GraphRequest.executeAsync方法代码示例

本文整理汇总了Java中com.facebook.GraphRequest.executeAsync方法的典型用法代码示例。如果您正苦于以下问题:Java GraphRequest.executeAsync方法的具体用法?Java GraphRequest.executeAsync怎么用?Java GraphRequest.executeAsync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.facebook.GraphRequest的用法示例。


在下文中一共展示了GraphRequest.executeAsync方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getGraphMeRequestWithCacheAsync

import com.facebook.GraphRequest; //导入方法依赖的package包/类
public static void getGraphMeRequestWithCacheAsync(
        final String accessToken,
        final GraphMeRequestWithCacheCallback callback) {
    JSONObject cachedValue = ProfileInformationCache.getProfileInformation(accessToken);
    if (cachedValue != null) {
        callback.onSuccess(cachedValue);
        return;
    }

    GraphRequest.Callback graphCallback = new GraphRequest.Callback() {
        @Override
        public void onCompleted(GraphResponse response) {
            if (response.getError() != null) {
                callback.onFailure(response.getError().getException());
            } else {
                ProfileInformationCache.putProfileInformation(
                        accessToken,
                        response.getJSONObject());
                callback.onSuccess(response.getJSONObject());
            }
        }
    };
    GraphRequest graphRequest = getGraphMeRequestWithCache(accessToken);
    graphRequest.setCallback(graphCallback);
    graphRequest.executeAsync();
}
 
开发者ID:eviltnan,项目名称:kognitivo,代码行数:27,代码来源:Utility.java

示例2: subscribeActual

import com.facebook.GraphRequest; //导入方法依赖的package包/类
@Override
protected void subscribeActual(@NonNull SingleObserver<? super GraphResponse> observer) {
    mObserver = observer;

    GraphRequest request = GraphRequest.newMeRequest(mAccessToken, new GraphRequest.GraphJSONObjectCallback() {
        @Override
        public void onCompleted(JSONObject object, GraphResponse response) {

            if (response.getError() == null) {
                mObserver.onSuccess(response);
            } else {
                mObserver.onError(response.getError().getException());
            }
        }
    });

    Bundle parameters = new Bundle();
    parameters.putString("fields", mFields);
    request.setParameters(parameters);
    request.executeAsync();
}
 
开发者ID:YouClap,项目名称:RxFacebook,代码行数:22,代码来源:RxFacebookGraphRequestSingle.java

示例3: revokePermission

import com.facebook.GraphRequest; //导入方法依赖的package包/类
public void revokePermission(final String permission) {
	AccessToken token = AccessToken.getCurrentAccessToken();

	String uri = "me/permissions/" + permission;

	GraphRequest graphRequest = GraphRequest.newDeleteObjectRequest(
	token, uri, new GraphRequest.Callback() {
		@Override
		public void onCompleted(GraphResponse response) {
			FacebookRequestError error = response.getError();
			if (error == null) {
				Utils.d("FB:Revoke:Response:" + response.toString());
				getPermissions();
			}
		}
	});

	graphRequest.executeAsync();
}
 
开发者ID:FrogSquare,项目名称:GodotFireBase,代码行数:20,代码来源:FacebookSignIn.java

示例4: revokeAccess

import com.facebook.GraphRequest; //导入方法依赖的package包/类
/** GraphRequest **/

	public void revokeAccess() {
		mAuth.signOut();

		AccessToken token = AccessToken.getCurrentAccessToken();
		GraphRequest graphRequest = GraphRequest.newDeleteObjectRequest(
		token, "me/permissions", new GraphRequest.Callback() {
			@Override
			public void onCompleted(GraphResponse response) {
				FacebookRequestError error = response.getError();
				if (error == null) {
					Utils.d("FB:Delete:Access" + response.toString());
				}
			}
		});

		graphRequest.executeAsync();
	}
 
开发者ID:FrogSquare,项目名称:GodotFireBase,代码行数:20,代码来源:FacebookSignIn.java

示例5: loadRequests

import com.facebook.GraphRequest; //导入方法依赖的package包/类
public void loadRequests() {
	AccessToken token = AccessToken.getCurrentAccessToken();

	GraphRequest myRequests = GraphRequest.newGraphPathRequest(
	token, "/me/apprequests", new GraphRequest.Callback() {
		@Override
		public void onCompleted(GraphResponse response) {
			FacebookRequestError error = response.getError();

			if (error == null) {
				JSONObject graphObject = response.getJSONObject();
				JSONArray data = graphObject.optJSONArray("data");

				Utils.callScriptFunc("pendingRequest", data.toString());
			} else { Utils.d("Response Error: " + error.toString()); }
		}
	});

	myRequests.executeAsync();
}
 
开发者ID:FrogSquare,项目名称:GDFacebook,代码行数:21,代码来源:FacebookSDK.java

示例6: deleteRequest

import com.facebook.GraphRequest; //导入方法依赖的package包/类
public static void deleteRequest (String requestId) {
	// delete Requets here GraphAPI.
	Utils.d("Deleting:Request:" + requestId);

	AccessToken token = AccessToken.getCurrentAccessToken();
	GraphRequest graphRequest = GraphRequest.newDeleteObjectRequest(
	token, requestId, new GraphRequest.Callback() {
		@Override
		public void onCompleted(GraphResponse response) {
			FacebookRequestError error = response.getError();
			if (error == null) { Utils.d("OnDelete:Req:" + response.toString()); }
		}
	});

	graphRequest.executeAsync();
}
 
开发者ID:FrogSquare,项目名称:GDFacebook,代码行数:17,代码来源:FacebookSDK.java

示例7: getUserDataFromRequest

import com.facebook.GraphRequest; //导入方法依赖的package包/类
public static void getUserDataFromRequest (String requestId) {
	// Grah Api to get user data from request.

	AccessToken token = AccessToken.getCurrentAccessToken();
	GraphRequest graphRequest = GraphRequest.newGraphPathRequest(
	token, requestId, new GraphRequest.Callback() {
		@Override
		public void onCompleted(GraphResponse response) {
			FacebookRequestError error = response.getError();

			if (error == null) { Utils.d("Response: " + response.toString()); }
			else { Utils.d("Error: " + response.toString()); }
		}
	});

	graphRequest.executeAsync();
}
 
开发者ID:FrogSquare,项目名称:GDFacebook,代码行数:18,代码来源:FacebookSDK.java

示例8: onSuccess

import com.facebook.GraphRequest; //导入方法依赖的package包/类
@Override
public void onSuccess(LoginResult loginResult) {
    GraphRequest request = GraphRequest.newMeRequest(
            loginResult.getAccessToken(),
            new GraphRequest.GraphJSONObjectCallback() {
                @Override
                public void onCompleted(JSONObject object, GraphResponse response) {
                    String socialId = null, name = null;
                    try {
                        socialId = object.getString("id");
                        name = object.getString("name");
                    }catch (Exception e){}

                    register(socialId, name);
                }
            });
    Bundle parameters = new Bundle();
    parameters.putString("fields", "id,name");
    request.setParameters(parameters);
    request.executeAsync();
}
 
开发者ID:lecrec,项目名称:lecrec-android,代码行数:22,代码来源:ActivityLaunchScreen.java

示例9: queryMe

import com.facebook.GraphRequest; //导入方法依赖的package包/类
private void queryMe(Result result) {
    GraphRequest request = GraphRequest.newMeRequest(
            AccessToken.getCurrentAccessToken(),
            (object, response) -> {
                try {
                    result.success(JsonConverter.convertToMap(object));
                } catch (JSONException e) {
                    result.error(TAG, "Error", e.getMessage());
                }
            });

    Bundle parameters = new Bundle();
    parameters.putString("fields", "id,name,email");
    request.setParameters(parameters);
    request.executeAsync();
}
 
开发者ID:markmooibroek,项目名称:apn_fb_login,代码行数:17,代码来源:ApnFbLoginPlugin.java

示例10: facebookLogin

import com.facebook.GraphRequest; //导入方法依赖的package包/类
private void facebookLogin(LoginResult loginResult){
    GraphRequest request = GraphRequest.newMeRequest(
            loginResult.getAccessToken(),
            new GraphRequest.GraphJSONObjectCallback(){
                @Override
                public void onCompleted(JSONObject object, GraphResponse response){
                    JSONObject jsonObject = response.getJSONObject();
                    UserAccountControl userAccountControl = UserAccountControl
                            .getInstance(getApplicationContext());
                    userAccountControl.authenticateLoginFb(object);
                    userAccountControl.logInUserFromFacebook(jsonObject);
                }
            });

    Bundle parameters = new Bundle();
    parameters.putString("fields", "id,name,email,gender");
    request.setParameters(parameters);
    request.executeAsync();

}
 
开发者ID:fga-gpp-mds,项目名称:2017.1-Trezentos,代码行数:21,代码来源:LoginActivity.java

示例11: facebookLogin

import com.facebook.GraphRequest; //导入方法依赖的package包/类
private void facebookLogin(LoginResult loginResult) {
    GraphRequest request = GraphRequest.newMeRequest(
            loginResult.getAccessToken(),
            new GraphRequest.GraphJSONObjectCallback() {
                @Override
                public void onCompleted(JSONObject object, GraphResponse response) {

                    UserAccountControl userAccountControl = UserAccountControl
                            .getInstance(getApplicationContext());
                    userAccountControl.authenticateLoginFb(object);
                }
            });

    Bundle parameters = new Bundle();
    parameters.putString("fields", "id,name,email,gender");
    request.setParameters(parameters);
    request.executeAsync();
}
 
开发者ID:fga-gpp-mds,项目名称:2017.1-Trezentos,代码行数:19,代码来源:LoginActivity.java

示例12: onSuccess

import com.facebook.GraphRequest; //导入方法依赖的package包/类
@Override
public void onSuccess(LoginResult loginResult) {
    final String fbAccessToken = loginResult.getAccessToken().getToken();
    PreferenceManager.getDefaultSharedPreferences(context).edit().putString(TOKEN_FB_KEY,fbAccessToken);
    Bundle parameters = new Bundle();
    parameters.putString("fields", "id,name,email");
    GraphRequest request = GraphRequest.newMeRequest(loginResult.getAccessToken(), new GraphRequest.GraphJSONObjectCallback() {
        @Override
        public void onCompleted(JSONObject object, GraphResponse response) {
            if (onFacebookEvent != null) {
                InfoSocial infoSocial = new InfoSocial();
                infoSocial.setAccessToken(fbAccessToken);
                infoSocial.setName(object.optString("name"));
                infoSocial.setEmail(object.optString("email"));
                infoSocial.setUserId(object.optString("id"));
                onFacebookEvent.onFacebookSuccess(infoSocial);
            }
        }
    });
    request.setParameters(parameters);
    request.executeAsync();
}
 
开发者ID:harrylefit,项目名称:eazysocial,代码行数:23,代码来源:FacebookManager.java

示例13: requestGraphData

import com.facebook.GraphRequest; //导入方法依赖的package包/类
/**
 * Requests user graph data
 * Use permission parameters e.g. "id, first_name, last_name, email, gender"
 *
 * @param accessToken
 * @param permissionParams
 * @param onFacebookGraphResponse
 */
public void requestGraphData(final AccessToken accessToken,
                             String permissionParams,
                             final OnFacebookGraphResponse onFacebookGraphResponse) {

    GraphRequest request = GraphRequest.newMeRequest(accessToken,
            (object, response) -> {

                if (object == null) {
                    Log.d(TAG, "Response is null");
                    return;
                }

                Log.d(TAG, "Object received: " + object.toString());

                onFacebookGraphResponse.onCompleted(object, response);
            }
    );

    Bundle parameters = new Bundle();

    parameters.putString("fields", permissionParams);

    request.setParameters(parameters);
    request.executeAsync();
}
 
开发者ID:Telecooperation,项目名称:assistance-platform-client-sdk-android,代码行数:34,代码来源:FacebookProvider.java

示例14: getUserEmail

import com.facebook.GraphRequest; //导入方法依赖的package包/类
private void getUserEmail(AccessToken accessToken) {
    GraphRequest request = GraphRequest.newMeRequest(accessToken, new GraphRequest.GraphJSONObjectCallback() {
        @Override
        public void onCompleted(JSONObject object, GraphResponse response) {
            try {
                updateUserData(object.getString("email"));
            } catch (JSONException e) {
                updateUserData("");
                e.printStackTrace();
            }
        }
    });
    Bundle parameters = new Bundle();
    parameters.putString("fields", "id,email");
    request.setParameters(parameters);
    request.executeAsync();
}
 
开发者ID:Hotmart-Org,项目名称:zum-android,代码行数:18,代码来源:SignUpActivity.java

示例15: getFBUserInfo

import com.facebook.GraphRequest; //导入方法依赖的package包/类
private void getFBUserInfo(final UserDataCallback userDataCallback) {
    final FBUser fbUser = new FBUser();
    GraphRequest request = GraphRequest.newMeRequest(AccessToken.getCurrentAccessToken(), new GraphRequest.GraphJSONObjectCallback() {
        @Override
        public void onCompleted(JSONObject object, GraphResponse response) {
            try {
                fbUser.username = object.getString("name");
                fbUser.userId = object.getString("id");
                userDataCallback.userData(fbUser);
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    });
    request.executeAsync();
}
 
开发者ID:FBDevelopersMexico,项目名称:Simple-Facebook-Login,代码行数:17,代码来源:FbUserDataActivity.java


注:本文中的com.facebook.GraphRequest.executeAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。