當前位置: 首頁>>代碼示例>>Java>>正文


Java GraphResponse類代碼示例

本文整理匯總了Java中com.facebook.GraphResponse的典型用法代碼示例。如果您正苦於以下問題:Java GraphResponse類的具體用法?Java GraphResponse怎麽用?Java GraphResponse使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


GraphResponse類屬於com.facebook包,在下文中一共展示了GraphResponse類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: transform

import com.facebook.GraphResponse; //導入依賴的package包/類
private List<Profile> transform(GraphResponse response) {
    Gson gson = new GsonBuilder()
            .registerTypeAdapter(Date.class, new GsonDateTypeAdapter())
            .create();
    String data = null;
    try {
        data = response.getJSONObject().has("data") ?
                response.getJSONObject().get("data").toString() :
                response.getJSONObject().toString();
    } catch (JSONException e) {
        e.printStackTrace();
    }
    Type listType = new TypeToken<List<Profile>>() {
    }.getType();
    return gson.fromJson(data, listType);
}
 
開發者ID:WassimBenltaief,項目名稱:ReactiveFB,代碼行數:17,代碼來源:FriendsActivity.java

示例2: shareLinkContent

import com.facebook.GraphResponse; //導入依賴的package包/類
private void shareLinkContent(final ShareLinkContent linkContent,
                              final FacebookCallback<Sharer.Result> callback) {
    final GraphRequest.Callback requestCallback = new GraphRequest.Callback() {
        @Override
        public void onCompleted(GraphResponse response) {
            final JSONObject data = response.getJSONObject();
            final String postId = (data == null ? null : data.optString("id"));
            ShareInternalUtility.invokeCallbackWithResults(callback, postId, response);
        }
    };
    final Bundle parameters = new Bundle();
    this.addCommonParameters(parameters, linkContent);
    parameters.putString("message", this.getMessage());
    parameters.putString("link", Utility.getUriString(linkContent.getContentUrl()));
    parameters.putString("picture", Utility.getUriString(linkContent.getImageUrl()));
    parameters.putString("name", linkContent.getContentTitle());
    parameters.putString("description", linkContent.getContentDescription());
    parameters.putString("ref", linkContent.getRef());
    new GraphRequest(
            AccessToken.getCurrentAccessToken(),
            getGraphPath("feed"),
            parameters,
            HttpMethod.POST,
            requestCallback).executeAsync();
}
 
開發者ID:eviltnan,項目名稱:kognitivo,代碼行數:26,代碼來源:ShareApi.java

示例3: getGraphMeRequestWithCacheAsync

import com.facebook.GraphResponse; //導入依賴的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

示例4: subscribeActual

import com.facebook.GraphResponse; //導入依賴的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

示例5: getPermissions

import com.facebook.GraphResponse; //導入依賴的package包/類
public void getPermissions() {
	String uri = "me/permissions/";

	new GraphRequest(AccessToken.getCurrentAccessToken(),
	uri, null, HttpMethod.GET,
		new GraphRequest.Callback() {
			public void onCompleted(GraphResponse response) {
				/* handle the result */
				JSONArray data = response.getJSONObject().optJSONArray("data");
				mUserPermissions.clear();

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

					if (dd.optString("status").equals("granted")) {
						mUserPermissions
						.add(dd.optString("permission"));
					}
				}
			}
		}
	).executeAsync();
}
 
開發者ID:FrogSquare,項目名稱:GodotFireBase,代碼行數:24,代碼來源:FacebookSignIn.java

示例6: revokePermission

import com.facebook.GraphResponse; //導入依賴的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

示例7: revokeAccess

import com.facebook.GraphResponse; //導入依賴的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

示例8: loadRequests

import com.facebook.GraphResponse; //導入依賴的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

示例9: deleteRequest

import com.facebook.GraphResponse; //導入依賴的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

示例10: getUserDataFromRequest

import com.facebook.GraphResponse; //導入依賴的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

示例11: onSuccess

import com.facebook.GraphResponse; //導入依賴的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

示例12: facebookLogin

import com.facebook.GraphResponse; //導入依賴的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

示例13: facebookLogin

import com.facebook.GraphResponse; //導入依賴的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

示例14: onCompleted

import com.facebook.GraphResponse; //導入依賴的package包/類
@Override
public void onCompleted(JSONObject object, GraphResponse response) {
  try {
    SocialUser user = new SocialUser();
    user.userId = object.getString("id");
    user.accessToken = AccessToken.getCurrentAccessToken().getToken();
    user.photoUrl = String.format(PHOTO_URL, user.userId);
    SocialUser.Profile profile = new SocialUser.Profile();
    profile.email = object.has("email")? object.getString("email") : "";
    profile.name = object.has("name")? object.getString("name"): "";
    profile.pageLink = object.has("link")? object.getString("link"): "";
    user.profile = profile;
    SocialLoginManager.getInstance(this).onLoginSuccess(user);
  } catch (JSONException e) {
    SocialLoginManager.getInstance(this).onLoginError(e.getCause());
  }

  LoginManager.getInstance().logOut();

  finish();
}
 
開發者ID:jaychang0917,項目名稱:SocialLoginManager,代碼行數:22,代碼來源:FbLoginHiddenActivity.java

示例15: onSuccess

import com.facebook.GraphResponse; //導入依賴的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


注:本文中的com.facebook.GraphResponse類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。