本文整理汇总了Java中com.facebook.GraphRequest.executeAndWait方法的典型用法代码示例。如果您正苦于以下问题:Java GraphRequest.executeAndWait方法的具体用法?Java GraphRequest.executeAndWait怎么用?Java GraphRequest.executeAndWait使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.facebook.GraphRequest
的用法示例。
在下文中一共展示了GraphRequest.executeAndWait方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: executeGraphRequestSynchronously
import com.facebook.GraphRequest; //导入方法依赖的package包/类
protected void executeGraphRequestSynchronously(Bundle parameters) {
GraphRequest request = new GraphRequest(
uploadContext.accessToken,
String.format(Locale.ROOT, "%s/videos", uploadContext.graphNode),
parameters,
HttpMethod.POST,
null);
GraphResponse response = request.executeAndWait();
if (response != null) {
FacebookRequestError error = response.getError();
JSONObject responseJSON = response.getJSONObject();
if (error != null) {
if (!attemptRetry(error.getSubErrorCode())) {
handleError(new FacebookGraphResponseException(response, ERROR_UPLOAD));
}
} else if (responseJSON != null) {
try {
handleSuccess(responseJSON);
} catch (JSONException e) {
endUploadWithFailure(new FacebookException(ERROR_BAD_SERVER_RESPONSE, e));
}
} else {
handleError(new FacebookException(ERROR_BAD_SERVER_RESPONSE));
}
} else {
handleError(new FacebookException(ERROR_BAD_SERVER_RESPONSE));
}
}
示例2: awaitGetGraphMeRequestWithCache
import com.facebook.GraphRequest; //导入方法依赖的package包/类
public static JSONObject awaitGetGraphMeRequestWithCache(
final String accessToken) {
JSONObject cachedValue = ProfileInformationCache.getProfileInformation(accessToken);
if (cachedValue != null) {
return cachedValue;
}
GraphRequest graphRequest = getGraphMeRequestWithCache(accessToken);
GraphResponse response = graphRequest.executeAndWait();
if (response.getError() != null) {
return null;
}
return response.getJSONObject();
}
示例3: reloadUserInfo
import com.facebook.GraphRequest; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void reloadUserInfo() {
clearUserInfo();
if (!isUserSignedIn()) {
return;
}
final Bundle parameters = new Bundle();
parameters.putString("fields", "name,picture.type(large)");
final GraphRequest graphRequest = new GraphRequest(AccessToken.getCurrentAccessToken(), "me");
graphRequest.setParameters(parameters);
GraphResponse response = graphRequest.executeAndWait();
JSONObject json = response.getJSONObject();
try {
userName = json.getString("name");
userImageUrl = json.getJSONObject("picture")
.getJSONObject("data")
.getString("url");
} catch (final JSONException jsonException) {
Log.e(LOG_TAG,
"Unable to get Facebook user info. " + jsonException.getMessage() + "\n" + response,
jsonException);
// Nothing much we can do here.
}
}
示例4: executeGraphRequestSynchronously
import com.facebook.GraphRequest; //导入方法依赖的package包/类
protected void executeGraphRequestSynchronously(Bundle parameters) {
GraphRequest request = new GraphRequest(
uploadContext.accessToken,
String.format(Locale.ROOT, "%s/videos", uploadContext.targetId),
parameters,
HttpMethod.POST,
null);
GraphResponse response = request.executeAndWait();
if (response != null) {
FacebookRequestError error = response.getError();
JSONObject responseJSON = response.getJSONObject();
if (error != null) {
if (!attemptRetry(error.getSubErrorCode())) {
handleError(new FacebookGraphResponseException(response, ERROR_UPLOAD));
}
} else if (responseJSON != null) {
try {
handleSuccess(responseJSON);
} catch (JSONException e) {
endUploadWithFailure(new FacebookException(ERROR_BAD_SERVER_RESPONSE, e));
}
} else {
handleError(new FacebookException(ERROR_BAD_SERVER_RESPONSE));
}
} else {
handleError(new FacebookException(ERROR_BAD_SERVER_RESPONSE));
}
}