本文整理汇总了Java中com.facebook.GraphRequest.setParameters方法的典型用法代码示例。如果您正苦于以下问题:Java GraphRequest.setParameters方法的具体用法?Java GraphRequest.setParameters怎么用?Java GraphRequest.setParameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.facebook.GraphRequest
的用法示例。
在下文中一共展示了GraphRequest.setParameters方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例2: 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();
}
示例3: 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();
}
示例4: 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();
}
示例5: 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();
}
示例6: 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();
}
示例7: 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
示例8: 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();
}
示例9: pageAbout
import com.facebook.GraphRequest; //导入方法依赖的package包/类
public void pageAbout(final String pageId){
GraphRequest request = GraphRequest.newGraphPathRequest(
AccessToken.getCurrentAccessToken(),
"/"+pageId,
new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse response) {
JSONObject object = response.getJSONObject();
String about = object.optString("about");
pageAbout_tv = (TextView)getActivity().findViewById(R.id.pageAbout);
pageAbout_tv.setText(about);
String description = object.optString("description");
pageAbout_tv = (TextView)getActivity().findViewById(R.id.pageDescription);
pageAbout_tv.setText(about);
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "about,description");
request.setParameters(parameters);
request.executeAsync();
}
示例10: getEventListFromFacebook
import com.facebook.GraphRequest; //导入方法依赖的package包/类
/**
* Attempts to get a list of the user's visible
* events from his/her facebook
*/
private void getEventListFromFacebook() {
if (InternetUtil.isOnline(getActivity())) {
SessionManager manager = new SessionManager(getActivity());
AccessToken token = manager.getAccessToken();
String path = manager.getString(getString(R.string.fb_field_id)) + "/events";
Bundle params = new Bundle();
params.putString(getString(R.string.fb_fields_key), getString(R.string.fb_ev_fields));
GraphRequest request = GraphRequest.newGraphPathRequest(token, path, this);
request.setParameters(params);
request.executeAsync();
}
else {
showNoInternetSnackBar();
}
}
示例11: ObtenerDatosFacebook
import com.facebook.GraphRequest; //导入方法依赖的package包/类
/**
* Metodo para obtener el nombre de usuario y la fotografia de Facebook
*/
private void ObtenerDatosFacebook() {
//Para obtener datos del perfil tenemos que hacer un GraphRequest
GraphRequest request = GraphRequest.newMeRequest(AccessToken.getCurrentAccessToken(), new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(final JSONObject object, GraphResponse response) {
//Obtenemos los datos del perfil
Profile perfil = Profile.getCurrentProfile();
//Lo mostramos en pantalla y lo guardamos
foto.setProfileId(perfil.getId());
nombre.setText(object.optString("name"));
}
});
//Añadimos los parametros que hemos requerido y ejecutamos la peticion
Bundle parameters = new Bundle();
parameters.putString("fields", "name");
request.setParameters(parameters);
request.executeAsync();
}
示例12: fetchAlbums
import com.facebook.GraphRequest; //导入方法依赖的package包/类
private void fetchAlbums() {
GraphRequest request = GraphRequest.newMeRequest(AccessToken.getCurrentAccessToken(),
new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(JSONObject object, GraphResponse response) {
progressBar.setVisibility(View.GONE);
try {
final List<String> urls = parseAlbumData(object.getJSONObject("albums").getJSONArray("data"));
if (urls.isEmpty()) {
Toast.makeText(PhotosActivity.this, "You have no albums on Facebook!", Toast.LENGTH_LONG).show();
return;
}
photos.clear();
photos.addAll(urls);
adapter.notifyDataSetChanged();
} catch (Exception e) {
e.printStackTrace();
}
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "name,albums.limit(100){name,picture{url}}");
request.setParameters(parameters);
request.executeAsync();
}
示例13: getAppSettingsQueryResponse
import com.facebook.GraphRequest; //导入方法依赖的package包/类
private static JSONObject getAppSettingsQueryResponse(String applicationId) {
Bundle appSettingsParams = new Bundle();
appSettingsParams.putString(APPLICATION_FIELDS, TextUtils.join(",", APP_SETTING_FIELDS));
GraphRequest request = GraphRequest.newGraphPathRequest(null, applicationId, null);
request.setSkipClientToken(true);
request.setParameters(appSettingsParams);
return request.executeAndWait().getJSONObject();
}
示例14: getUserInfo
import com.facebook.GraphRequest; //导入方法依赖的package包/类
private void getUserInfo(LoginResult result) {
GraphRequest.GraphJSONObjectCallback callback = new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(JSONObject object, GraphResponse response) {
if (object == null) {
responseListener.onResult(SocialType.FACEBOOK, ResultType.FAILURE, null);
return;
}
String id = RichUtils.getJSONString(object, "id");
String name = RichUtils.getJSONString(object, "name");
String email = RichUtils.getJSONString(object, "email");
String gender = RichUtils.getJSONString(object, "gender");
JSONObject data = RichUtils.getJSONObject(RichUtils.getJSONObject(object, "picture"), "data");
String profilePicture = RichUtils.getJSONString(data, "url");
Map<UserInfoType, String> userInfoMap = new HashMap<>();
userInfoMap.put(UserInfoType.ID, id);
userInfoMap.put(UserInfoType.NAME, name);
userInfoMap.put(UserInfoType.EMAIL, email);
userInfoMap.put(UserInfoType.PROFILE_PICTURE, profilePicture);
userInfoMap.put(UserInfoType.GENDER, gender);
responseListener.onResult(SocialType.FACEBOOK, ResultType.SUCCESS, userInfoMap);
}
};
GraphRequest request = GraphRequest.newMeRequest(result.getAccessToken(), callback);
Bundle parameters = new Bundle();
parameters.putString("fields", "id, name, email, gender, birthday, picture");
request.setParameters(parameters);
request.executeAsync();
}
示例15: facebookGraphRequest
import com.facebook.GraphRequest; //导入方法依赖的package包/类
public void facebookGraphRequest() {
if (!FacebookSdk.isInitialized()) {
FacebookSdk.sdkInitialize(getApplicationContext());
AppEventsLogger.activateApp(getApplication());
}
GraphRequest request = GraphRequest.newMeRequest(
//loginResult.getAccessToken(),
AccessToken.getCurrentAccessToken(),
new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(JSONObject object, GraphResponse response) {
Log.v(TAG, response.toString());
// Application code
try {
if (object == null) return;
Person person = new Person();
String name = object.getString("name");
String gender = object.getString("gender"); // 01/31/1980 format
String id = object.getString("id");
Log.d(TAG, "Name: " + name + ". Gender: " + gender);
person.setName(name);
person.setId(id);
person.setLink("http://www.facebook.com/" + id);
dataKey = mPlaceReference.push().getKey();
mPlaceReference.child(dataKey).setValue(person);
} catch (JSONException e) {
e.printStackTrace();
}
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,email,gender,birthday");
request.setParameters(parameters);
request.executeAsync();
}