本文整理汇总了Java中com.facebook.Request.newMeRequest方法的典型用法代码示例。如果您正苦于以下问题:Java Request.newMeRequest方法的具体用法?Java Request.newMeRequest怎么用?Java Request.newMeRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.facebook.Request
的用法示例。
在下文中一共展示了Request.newMeRequest方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
}
示例2: 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.");
}
}
示例3: 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);
}
示例4: 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());
}
}
示例5: populateLoggedInUser
import com.facebook.Request; //导入方法依赖的package包/类
private void populateLoggedInUser() {
final TextView txtUserDetails = (TextView) this.getActivity().findViewById(R.id.userDetails);
final Session session = Session.getActiveSession();
if (session != null && session.isOpened()) {
// If the session is open, make an API call to get user data
// and define a new callback to handle the response
Request request = Request.newMeRequest(session, new Request.GraphUserCallback() {
@Override
public void onCompleted(GraphUser user, Response response) {
// If the response is successful
if (session == Session.getActiveSession()) {
if (user != null) {
String user_ID = user.getId();//user id
String profileName = user.getName();//user's profile name
txtUserDetails.setText(user.getName());
}
}
}
});
Request.executeBatchAsync(request);
} else if (session == null || session.isClosed()) {
}
}
示例6: retrieveEmailAddress
import com.facebook.Request; //导入方法依赖的package包/类
public void retrieveEmailAddress() {
Request request = Request.newMeRequest(ParseFacebookUtils.getSession(),
new Request.GraphUserCallback() {
@Override
public void onCompleted(GraphUser user, Response response) {
if (user != null) {
try {
String email = user.getInnerJSONObject().get("email").toString();
ParseUser.getCurrentUser().setEmail(email);
ParseUser.getCurrentUser().saveEventually();
} catch (JSONException e) {
Log.e("CatChatInbox", "Failed to parse JSON from FB", e);
}
}
}
}
);
request.executeAsync();
}
示例7: logInAfterFacebookLogined
import com.facebook.Request; //导入方法依赖的package包/类
/**
* Facebook SDK의 로그인 함수를 호출한 뒤에, 세션이 열린 상태에서 로그인한다.
* callback을 통해 User 객체가 반환되고, 에러 발생시 HaruException을 반환한다.
*
* @param context Application Context
* @param callback Login Callback
*/
public static void logInAfterFacebookLogined(Context context,
final LoginCallback callback) {
Session activeSession = Session.getActiveSession();
if (activeSession != null && activeSession.isOpened()) {
// we need to retrieve user information
Request.newMeRequest(activeSession, new Request.GraphUserCallback() {
@Override
public void onCompleted(GraphUser user, Response response) {
// Log in to Haru server
User.socialLogin("facebook",
user.getId(),
Session.getActiveSession().getAccessToken(),
callback);
}
});
} else {
callback.done(null, new HaruException(
"Facebook session is not opened!" +
"you need to login using Facebook SDK before calling this."));
}
}
示例8: createBuyerChannel
import com.facebook.Request; //导入方法依赖的package包/类
private void createBuyerChannel() {
final Session session = ParseFacebookUtils.getSession();
if (session != null && session.isOpened()) {
Request request = Request.newMeRequest(session, new Request.GraphUserCallback() {
@Override public void onCompleted(GraphUser user, Response response) {
if (session == Session.getActiveSession()) {
if (user != null) {
facebookId = user.getId();
String c = buyerProfile != null ? buyerProfile + adId : facebookId + adId;
subscribeChannel(c);
publishMessage(c, facebookId, adId);
}
}
}
});
Request.executeBatchAsync(request);
}
}
示例9: call
import com.facebook.Request; //导入方法依赖的package包/类
@Override
public void call(final Session session, SessionState state, Exception exception) {
if (state.isOpened()) {
Log.d("Facebook token", session.getAccessToken());
Request meRequest = Request.newMeRequest(session, new Request.GraphUserCallback() {
@Override
public void onCompleted(GraphUser user, Response response) {
Login login = new Login(user.getProperty("email").toString(), session.getAccessToken(), "facebook");
new CheckUserCredentials(MainActivity.this).execute(login);
session.closeAndClearTokenInformation();
}
});
meRequest.executeAsync();
}
}
示例10: fetchUserInfo
import com.facebook.Request; //导入方法依赖的package包/类
private void fetchUserInfo() {
if (fetchUserInfo) {
final Session currentSession = sessionTracker.getOpenSession();
if (currentSession != null) {
if (currentSession != userInfoSession) {
Request request = Request.newMeRequest(currentSession, new Request.GraphUserCallback() {
@Override
public void onCompleted(GraphUser me, Response response) {
if (currentSession == sessionTracker.getOpenSession()) {
user = me;
if (userInfoChangedCallback != null) {
userInfoChangedCallback.onUserInfoFetched(user);
}
}
if (response.getError() != null) {
handleError(response.getError().getException());
}
}
});
Request.executeBatchAsync(request);
userInfoSession = currentSession;
}
} else {
user = null;
if (userInfoChangedCallback != null) {
userInfoChangedCallback.onUserInfoFetched(user);
}
}
}
}
示例11: getUser
import com.facebook.Request; //导入方法依赖的package包/类
@Override
public void getUser(final Callback<SocialMember> callback) {
if (notifyIfNotLoggedIn(callback)) {
return;
}
//If the profile for the current user has already been fetched use the cached result.
if (userProfile != null) {
callback.onSuccess(userProfile);
return;
}
Session session = Session.getActiveSession();
Request request = Request.newMeRequest(session, new Request.GraphUserCallback() {
@Override
public void onCompleted(GraphUser user, Response response) {
if (!notifyIfError(response, callback)) {
logger.debug(user.getUsername() + ":" + user.getName() + ":" + user.getFirstName()
+ ":" + user.getLastName() + ":" + user.getId());
logger.debug(user.getProperty("email") + "");
SocialMember member = new SocialMember(Long.parseLong(user.getId()), user.getName());
member.setEmail(user.getProperty("email") + "");
callback.onSuccess(member);
}
}
});
Bundle params = request.getParameters();
params.putString("fields", "email,id,name");
request.setParameters(params);
request.executeAsync();
}
示例12: fetchUserInfo
import com.facebook.Request; //导入方法依赖的package包/类
private void fetchUserInfo()
{
final Session localSession = getSession();
if ((localSession != null) && (localSession.isOpened()))
{
if (localSession != this.userInfoSession)
{
Request localRequest = Request.newMeRequest(localSession, new Request.GraphUserCallback()
{
public void onCompleted(GraphUser paramAnonymousGraphUser, Response paramAnonymousResponse)
{
if (localSession == UserSettingsFragment.this.getSession())
{
UserSettingsFragment.access$002(UserSettingsFragment.this, paramAnonymousGraphUser);
UserSettingsFragment.this.updateUI();
}
if (paramAnonymousResponse.getError() != null)
UserSettingsFragment.this.loginButton.handleError(paramAnonymousResponse.getError().getException());
}
});
Bundle localBundle = new Bundle();
localBundle.putString("fields", REQUEST_FIELDS);
localRequest.setParameters(localBundle);
Request.executeBatchAsync(new Request[] { localRequest });
this.userInfoSession = localSession;
}
}
else
this.user = null;
}
示例13: checkFacebookLogin
import com.facebook.Request; //导入方法依赖的package包/类
private String checkFacebookLogin() {
final Session session = ParseFacebookUtils.getSession();
if (session != null && session.isOpened()) {
Request request = Request.newMeRequest(session, new Request.GraphUserCallback() {
@Override public void onCompleted(GraphUser user, Response response) {
if (session == Session.getActiveSession()) {
facebookId = user.getId();
}
}
});
Request.executeBatchAsync(request);
}
return facebookId;
}
示例14: onSessionStateChanged
import com.facebook.Request; //导入方法依赖的package包/类
public void onSessionStateChanged(final com.facebook.Session session, SessionState state, Exception exception) {
if (session != null && session.isOpened()) {
Log.i(TAG, "Usu�rio conectado!");
// fazer pedido para o /me API
Request req = Request.newMeRequest(session, new Request.GraphUserCallback() {
@Override
public void onCompleted(GraphUser user, Response response) {
if (user != null) {
TextView nameText = (TextView) findViewById(R.id.name);
nameText.setText(user.getFirstName() + " " + user.getLastName());
TextView emailText = (TextView) findViewById(R.id.email);
emailText.setText(user.getProperty("email").toString());
ProfilePictureView ppv = (ProfilePictureView) findViewById(R.id.fbImg);
ppv.setVisibility(View.VISIBLE);
ppv.setProfileId(user.getId());
Button listarButton = (Button) findViewById(R.id.listarButton);
listarButton.setVisibility(View.VISIBLE);
recoverFriends(session);
}
}
});
req.executeAsync();
}
else {
Log.i(TAG, "Usu�rio desconectado!");
}
}
示例15: makeMeRequest
import com.facebook.Request; //导入方法依赖的package包/类
private void makeMeRequest() {
Request request = Request.newMeRequest(ParseFacebookUtils.getSession(),
new Request.GraphUserCallback() {
@Override public void onCompleted(GraphUser user, Response response) {
if (user != null) {
setGalleryByProfile(user.getId());
}
}
}
);
request.executeAsync();
}