本文整理汇总了Java中com.facebook.GraphRequest.Callback方法的典型用法代码示例。如果您正苦于以下问题:Java GraphRequest.Callback方法的具体用法?Java GraphRequest.Callback怎么用?Java GraphRequest.Callback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.facebook.GraphRequest
的用法示例。
在下文中一共展示了GraphRequest.Callback方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shareLinkContent
import com.facebook.GraphRequest; //导入方法依赖的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();
}
示例2: getGraphMeRequestWithCacheAsync
import com.facebook.GraphRequest; //导入方法依赖的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();
}
示例3: shareLinkContent
import com.facebook.GraphRequest; //导入方法依赖的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();
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(),
"/me/feed",
parameters,
HttpMethod.POST,
requestCallback).executeAsync();
}
示例4: DefaultCallback
import com.facebook.GraphRequest; //导入方法依赖的package包/类
/**
* @param callback
* @return
*/
private GraphRequest.Callback DefaultCallback(final Callback callback) {
GraphRequest.Callback GraphRequestcallback = new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse graphResponse) {
if (graphResponse.getError() != null) {
callback.fail();
if (isDebug) {
}
} else {
if (isDebug) {
}
callback.complete(graphResponse, graphResponse.getJSONObject());
}
}
};
return GraphRequestcallback;
}
示例5: requestFacebookCoverPhoto
import com.facebook.GraphRequest; //导入方法依赖的package包/类
public void requestFacebookCoverPhoto(AccessToken accessToken, final FacebookGetLoginUserCallback callback) {
if (NetworkUtils.getInstance().isOnline()) {
Bundle params = new Bundle();
params.putString("fields", "cover");
GraphRequest request = new GraphRequest(
accessToken,
"me",
params,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
try {
JSONObject coverResponse = response.getJSONObject().getJSONObject("cover");
String coverUrl = coverResponse.getString("source");
UserModel.getInstance().addFacebookCoverUrl(coverUrl);
callback.onSuccess();
} catch (JSONException e) {
e.printStackTrace();
}
}
}
);
request.executeAsync();
}
}
示例6: requestFacebookProfilePhoto
import com.facebook.GraphRequest; //导入方法依赖的package包/类
public void requestFacebookProfilePhoto(AccessToken accessToken, final FacebookGetLoginUserCallback callback) {
if (NetworkUtils.getInstance().isOnline()) {
Bundle params = new Bundle();
params.putString("redirect", "false");
params.putString("type", "large");
GraphRequest request = new GraphRequest(
accessToken,
"me/picture",
params,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
try {
String profilePhotoUrl = response.getJSONObject().getJSONObject("data").getString("url");
UserModel.getInstance().addFacebookProfileUrl(profilePhotoUrl);
callback.onSuccess();
} catch (JSONException e) {
e.printStackTrace();
}
}
}
);
request.executeAsync();
}
}
示例7: shareLinkContent
import com.facebook.GraphRequest; //导入方法依赖的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(),
"/me/feed",
parameters,
HttpMethod.POST,
requestCallback).executeAsync();
}
示例8: publishStory
import com.facebook.GraphRequest; //导入方法依赖的package包/类
private void publishStory(final String message) {
if (AccessToken.getCurrentAccessToken() != null) {
Bundle postParams = new Bundle();
postParams.putString("message", message);
GraphRequest.Callback callback = new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse graphResponse) {
FacebookRequestError error = graphResponse.getError();
if (error != null) {
if (eventHandler != null) {
Log.sysOut("$#$#$ " + error);
eventHandler.stopProgress();
eventHandler.onFacebookError(error
.getErrorMessage());
}
return;
}
if (eventHandler != null) {
eventHandler.stopProgress();
eventHandler.onRecievePost(message);
}
}
};
GraphRequest request = new GraphRequest(AccessToken.getCurrentAccessToken(), "feed", postParams,
HttpMethod.POST, callback);
request.executeAsync();
} else if (eventHandler != null) eventHandler.onFacebookError(activity.getString(R.string.facebook_you_must_login_first_toast));
}
示例9: RealGraphRequestWrapper
import com.facebook.GraphRequest; //导入方法依赖的package包/类
public RealGraphRequestWrapper(AccessToken accessToken,
String graphPath,
Bundle parameters,
HttpMethod httpMethod,
GraphRequest.Callback callback) {
super(accessToken, graphPath, parameters, httpMethod, callback);
}
示例10: AbstractGraphRequestWrapper
import com.facebook.GraphRequest; //导入方法依赖的package包/类
public AbstractGraphRequestWrapper(
AccessToken accessToken,
String graphPath,
Bundle parameters,
HttpMethod httpMethod,
GraphRequest.Callback callback) {
this.request = new GraphRequest(accessToken, graphPath, parameters, httpMethod, callback);
}
示例11: MockGraphRequestWrapper
import com.facebook.GraphRequest; //导入方法依赖的package包/类
public MockGraphRequestWrapper(AccessToken accessToken,
String graphPath,
Bundle parameters,
HttpMethod httpMethod,
GraphRequest.Callback callback) {
super(accessToken, graphPath, parameters, httpMethod, callback);
}
示例12: getFeedGraphRequest
import com.facebook.GraphRequest; //导入方法依赖的package包/类
public static GraphRequest getFeedGraphRequest(String pageId, GraphRequest.Callback callback) {
return new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/" + pageId + "/feed?include_hidden=true&fields=message,created_time,is_hidden,insights.metric(post_impressions)",
null,
HttpMethod.GET,
callback
);
}
示例13: getPromotablePostsGraphRequest
import com.facebook.GraphRequest; //导入方法依赖的package包/类
public static GraphRequest getPromotablePostsGraphRequest(String pageId, GraphRequest.Callback callback) {
return new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/" + pageId + "/promotable_posts?is_published=false&include_hidden=true&fields=message,created_time,is_hidden,insights.metric(post_impressions)",
null,
HttpMethod.GET,
callback
);
}
示例14: getMeAccoountsGraphRequest
import com.facebook.GraphRequest; //导入方法依赖的package包/类
public static GraphRequest getMeAccoountsGraphRequest(GraphRequest.Callback callback) {
return new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/me/accounts",
null,
HttpMethod.GET,
callback
);
}
示例15: shareVideoContent
import com.facebook.GraphRequest; //导入方法依赖的package包/类
private void shareVideoContent(final ShareVideoContent videoContent,
final FacebookCallback<Sharer.Result> callback) {
final GraphRequest.Callback requestCallback = new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse response) {
String postId = null;
if (response != null) {
JSONObject responseJSON = response.getJSONObject();
if (responseJSON != null) {
postId = responseJSON.optString("id");
}
}
ShareInternalUtility.invokeCallbackWithResults(callback, postId, response);
}
};
GraphRequest videoRequest;
try {
videoRequest = ShareInternalUtility.newUploadVideoRequest(
AccessToken.getCurrentAccessToken(),
videoContent.getVideo().getLocalUrl(),
requestCallback);
} catch (final FileNotFoundException ex) {
ShareInternalUtility.invokeCallbackWithException(callback, ex);
return;
}
final Bundle parameters = videoRequest.getParameters();
parameters.putString("title", videoContent.getContentTitle());
parameters.putString("description", videoContent.getContentDescription());
parameters.putString("ref", videoContent.getRef());
videoRequest.setParameters(parameters);
videoRequest.executeAsync();
}