本文整理匯總了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));
}
}