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


Java Request類代碼示例

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


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

示例1: getUserFriendList

import com.facebook.Request; //導入依賴的package包/類
public static  Promise<List<GraphUser>, BError, Void>  getUserFriendList(){

        final Deferred<List<GraphUser>, BError, Void> deferred = new DeferredObject<>();

        
        if (!Session.getActiveSession().getState().isOpened())
        {
            return deferred.reject(new BError(BError.Code.SESSION_CLOSED));
        }
        Request req = Request.newMyFriendsRequest(Session.getActiveSession(), new Request.GraphUserListCallback() {
            @Override
            public void onCompleted(List<GraphUser> users, Response response) {
                deferred.resolve(users);
            }
        });

        req.executeAsync();
        
        return deferred.promise();
    }
 
開發者ID:MobileDev418,項目名稱:chat-sdk-android-push-firebase,代碼行數:21,代碼來源:BFacebookManager.java

示例2: createRequest

import com.facebook.Request; //導入依賴的package包/類
private Request createRequest(String userID, Set<String> extraFields, Session session) {
    Request request = Request.newGraphPathRequest(session, userID + "/friends", null);

    Set<String> fields = new HashSet<String>(extraFields);
    String[] requiredFields = new String[]{
            ID,
            NAME
    };
    fields.addAll(Arrays.asList(requiredFields));

    String pictureField = adapter.getPictureFieldSpecifier();
    if (pictureField != null) {
        fields.add(pictureField);
    }

    Bundle parameters = request.getParameters();
    parameters.putString("fields", TextUtils.join(",", fields));
    request.setParameters(parameters);

    return request;
}
 
開發者ID:MobileDev418,項目名稱:AndroidBackendlessChat,代碼行數:22,代碼來源:FriendPickerFragment.java

示例3: requestUserData

import com.facebook.Request; //導入依賴的package包/類
public void requestUserData( Session session ) {
    // Request user data and show the results
    Request.newMeRequest(session, new Request.GraphUserCallback() {

        @Override
        public void onCompleted(GraphUser user, Response response) {
            if (user != null) {
               User currentUser = new User();
                currentUser.setUserId(user.getId());
                currentUser.setUserName(user.getUsername());
                currentUser.setFirstName(user.getFirstName());
                currentUser.setLastName(user.getLastName());
                currentUser.setDisplayName(user.getName());
                currentUser.setMail((String) user.getProperty("email"));
                currentUser.setProviderDisplayName("Facebook");
                currentUser.setProvider(PROVIDER_NAME);
               FbLoginDelegate.this.mUserHelper.setCurrentUser(currentUser);
                if ( mUserSessionCallback != null) {
                    mUserSessionCallback.onLogin();
                }
            }
        }
    }).executeAsync();
}
 
開發者ID:alessandrogurgel,項目名稱:pedefacil,代碼行數:25,代碼來源:FbLoginDelegate.java

示例4: queryAppSettings

import com.facebook.Request; //導入依賴的package包/類
public static FetchedAppSettings queryAppSettings(final String applicationId, final boolean forceRequery) {

        // Cache the last app checked results.
        if (!forceRequery && fetchedAppSettings.containsKey(applicationId)) {
            return fetchedAppSettings.get(applicationId);
        }

        Bundle appSettingsParams = new Bundle();
        appSettingsParams.putString(APPLICATION_FIELDS, TextUtils.join(",", APP_SETTING_FIELDS));

        Request request = Request.newGraphPathRequest(null, applicationId, null);
        request.setParameters(appSettingsParams);

        GraphObject supportResponse = request.executeAndWait().getGraphObject();
        FetchedAppSettings result = new FetchedAppSettings(
                safeGetBooleanFromResponse(supportResponse, SUPPORTS_ATTRIBUTION),
                safeGetBooleanFromResponse(supportResponse, SUPPORTS_IMPLICIT_SDK_LOGGING));

        fetchedAppSettings.put(applicationId, result);

        return result;
    }
 
開發者ID:yeloapp,項目名稱:yelo-android,代碼行數:23,代碼來源:Utility.java

示例5: fetchUserInfo

import com.facebook.Request; //導入依賴的package包/類
private void fetchUserInfo() {
    final Session currentSession = getSession();
    if (currentSession != null && currentSession.isOpened()) {
        if (currentSession != userInfoSession) {
            Request request = Request.newMeRequest(currentSession, new Request.GraphUserCallback() {
                @Override
                public void onCompleted(GraphUser me, Response response) {
                    if (currentSession == getSession()) {
                        user = me;
                        updateUI();
                    }
                    if (response.getError() != null) {
                        loginButton.handleError(response.getError().getException());
                    }
                }
            });
            Bundle parameters = new Bundle();
            parameters.putString(FIELDS, REQUEST_FIELDS);
            request.setParameters(parameters);
            Request.executeBatchAsync(request);
            userInfoSession = currentSession;
        }
    } else {
        user = null;
    }
}
 
開發者ID:yeloapp,項目名稱:yelo-android,代碼行數:27,代碼來源:UserSettingsFragment.java

示例6: followNextLink

import com.facebook.Request; //導入依賴的package包/類
public void followNextLink() {
    if (nextRequest != null) {
        appendResults = true;
        currentRequest = nextRequest;

        currentRequest.setCallback(new Request.Callback() {
            @Override
            public void onCompleted(Response response) {
                requestCompleted(response);
            }
        });

        loading = true;
        CacheableRequestBatch batch = putRequestIntoBatch(currentRequest, skipRoundtripIfCached);
        Request.executeBatchAsync(batch);
    }
}
 
開發者ID:yeloapp,項目名稱:yelo-android,代碼行數:18,代碼來源:GraphObjectPagingLoader.java

示例7: requestCompleted

import com.facebook.Request; //導入依賴的package包/類
private void requestCompleted(Response response) {
    Request request = response.getRequest();
    if (request != currentRequest) {
        return;
    }

    loading = false;
    currentRequest = null;

    FacebookRequestError requestError = response.getError();
    FacebookException exception = (requestError == null) ? null : requestError.getException();
    if (response.getGraphObject() == null && exception == null) {
        exception = new FacebookException("GraphObjectPagingLoader received neither a result nor an error.");
    }

    if (exception != null) {
        nextRequest = null;

        if (onErrorListener != null) {
            onErrorListener.onError(exception, this);
        }
    } else {
        addResults(response);
    }
}
 
開發者ID:yeloapp,項目名稱:yelo-android,代碼行數:26,代碼來源:GraphObjectPagingLoader.java

示例8: createRequest

import com.facebook.Request; //導入依賴的package包/類
private Request createRequest(String userID, Set<String> extraFields, Session session) {
    Request request = Request.newGraphPathRequest(session, userID + friendPickerType.getRequestPath(), null);

    Set<String> fields = new HashSet<String>(extraFields);
    String[] requiredFields = new String[]{
            ID,
            NAME
    };
    fields.addAll(Arrays.asList(requiredFields));

    String pictureField = adapter.getPictureFieldSpecifier();
    if (pictureField != null) {
        fields.add(pictureField);
    }

    Bundle parameters = request.getParameters();
    parameters.putString("fields", TextUtils.join(",", fields));
    request.setParameters(parameters);

    return request;
}
 
開發者ID:dannegm,項目名稱:BrillaMXAndroid,代碼行數:22,代碼來源:FriendPickerFragment.java

示例9: postStatus

import com.facebook.Request; //導入依賴的package包/類
public void postStatus(View view){
    EditText editText = (EditText) findViewById(R.id.editText);
    final String statusText = editText.getText().toString();
    Session session = Session.getActiveSession();
    if (session != null) {

        if (session.isOpened() && hasPublishPermission()) {
            Request request = Request
                    .newStatusUpdateRequest(Session.getActiveSession(), statusText, null, null, new Request.Callback() {
                        @Override
                        public void onCompleted(Response response) {
                            showPublishResult(statusText, response.getGraphObject(), response.getError());
                        }
                    });
            request.executeAsync();
            return;
        }
        else {
            Toast.makeText(this, getString(R.string.err_notConnected), Toast.LENGTH_SHORT).show();
        }
    }
    else {
        Toast.makeText(this, getString(R.string.err_notConnected), Toast.LENGTH_SHORT).show();
    }
}
 
開發者ID:jacquesgiraudel,項目名稱:TP-Formation-Android,代碼行數:26,代碼來源:TestFacebookActivity.java

示例10: onSessionStateChange

import com.facebook.Request; //導入依賴的package包/類
/**
 * Changes the UI when an interaction with the Session object occurs with the user.
 * @param session       The current active Session.
 * @param sessionState  The current state of the active Session.
 * @param e             An Exception if there is one.
 */
private void onSessionStateChange(Session session, SessionState sessionState, Exception e) {
    if (sessionState == SessionState.OPENED) {
        Log.d(TAG, "Successful login!");
        new Request(session, "/me", null, HttpMethod.GET, new Request.Callback() {
            @Override
            public void onCompleted(Response response) {
                JSONObject obj = response.getGraphObject().getInnerJSONObject();
                Log.d(TAG, "Got back " + obj + " from Facebook API.");
                UserSession.getInstance().setFacebookData(obj);
                getUserData();
            }
        }).executeAsync();
    } else if (e != null) { // handle exception

    }
}
 
開發者ID:danfang,項目名稱:house-devs,代碼行數:23,代碼來源:LoginFragment.java

示例11: call

import com.facebook.Request; //導入依賴的package包/類
@Override
public void call(Session session, SessionState state, Exception exception) {
	if (session.isOpened()) {
		setFacebookSession(session);
		// make request to the /me API
		Request.newMeRequest(session, new Request.GraphUserCallback() {

			// callback after Graph API response with user object
			@Override
			public void onCompleted(GraphUser user, Response response) {
				if (user != null) {
					Toast.makeText(LoginActivity.this,
							"Hello " + user.getName(), Toast.LENGTH_LONG)
							.show();
				}
			}
		}).executeAsync();
	}
}
 
開發者ID:jinman,項目名稱:snake-game-aws,代碼行數:20,代碼來源:LoginActivity.java

示例12: populateContact

import com.facebook.Request; //導入依賴的package包/類
public void populateContact() {
    final Session session = Session.getActiveSession();
    new Request(session, "/me/friends", null, HttpMethod.GET,
            new Request.Callback() {
                public void onCompleted(Response response) {

                    // Process the returned response
                    GraphObject graphObject = response.getGraphObject();
                    if (graphObject != null) {
                        // Check if there is extra data
                        if (graphObject.getProperty("data") != null) {
                                JSONArray arrayObject = (JSONArray) graphObject
                                        .getProperty("data");

                                int count = arrayObject.length();
                                if(count == 0)
                                    hasAppFriends = false;
                                // Ensure the user has at least one friend
                                //session.close();
                        }
                    }
                }

            }).executeAsync();
}
 
開發者ID:3bytessolutions,項目名稱:CallService-Facebook-sample,代碼行數:26,代碼來源:UserHome.java

示例13: onSessionStateChange

import com.facebook.Request; //導入依賴的package包/類
@Override
protected void onSessionStateChange(Session session, SessionState state, Exception exception){
    final TextView txtUserDetails = (TextView) mCurrentView.findViewById(R.id.mapViewLoggedInUser);
    if (session != null && session.isOpened()) {
        Request request = Request.newMeRequest(session, new Request.GraphUserCallback() {
            @Override
            public void onCompleted(GraphUser user,
                                    Response response) {
                if (user != null) {
                    txtUserDetails.setText("Logged in as " + user.getName());
                    System.out.println("onSessionStateChange: LoadNotes: session is open. username:"+user.getName());
                }
            }
        });
        Request.executeBatchAsync(request);
    } else if (session.isClosed()) {
        txtUserDetails.setText("");
        System.out.println("onSessionStateChange: LoadNotes: session was closed.");
    }
}
 
開發者ID:ZanyGnu,項目名稱:GeoNote,代碼行數:21,代碼來源:MapViewFragment.java

示例14: onSessionStateChangeP

import com.facebook.Request; //導入依賴的package包/類
private void onSessionStateChangeP(Session session, SessionState state, Exception exception)
{
    if (session != null && session.isOpened()) {
        Request request = Request.newMeRequest(session, new Request.GraphUserCallback() {
            @Override
            public void onCompleted(GraphUser user,
                                    Response response) {
                if (user != null) {
                    LoggedInUser = user;
                }
            }
        });
        Request.executeBatchAsync(request);
    } else if (session.isClosed()) {
        LoggedInUser = null;
    }

    onSessionStateChange(session, state, exception);
}
 
開發者ID:ZanyGnu,項目名稱:GeoNote,代碼行數:20,代碼來源:BaseFacebookHandlerFragment.java

示例15: onSessionStateChange

import com.facebook.Request; //導入依賴的package包/類
protected void onSessionStateChange(Session session, SessionState state, Exception exception){
    if (session != null && session.isOpened()) {
        logAndShowOnScreen("\nLogged in. Getting user details.");
        Request request = Request.newMeRequest(session, new Request.GraphUserCallback() {
            @Override
            public void onCompleted(GraphUser user,
                                    Response response) {
                if (user != null) {
                    System.out.println("onSessionStateChange: LoadNotes: session is open. username:"+user.getName());

                    loadNotes(getActivity(), user.getId());
                }
            }
        });
        Request.executeBatchAsync(request);
    } else {
        logAndShowOnScreen("\nUser not already logged in.");
        System.out.println("onSessionStateChange: LoadNotes: session was closed.");
        loadNotes(getActivity(), getLoggedInUsername());
    }
}
 
開發者ID:ZanyGnu,項目名稱:GeoNote,代碼行數:22,代碼來源:SplashScreenFragment.java


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