当前位置: 首页>>代码示例>>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;未经允许,请勿转载。