當前位置: 首頁>>代碼示例>>Java>>正文


Java GraphRequest.executeAndWait方法代碼示例

本文整理匯總了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));
    }
}
 
開發者ID:eviltnan,項目名稱:kognitivo,代碼行數:30,代碼來源:VideoUploader.java

示例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();
}
 
開發者ID:eviltnan,項目名稱:kognitivo,代碼行數:16,代碼來源:Utility.java

示例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.
    }
}
 
開發者ID:jtran064,項目名稱:PlatePicks-Android,代碼行數:28,代碼來源:FacebookSignInProvider.java

示例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));
    }
}
 
開發者ID:yudiandreanp,項目名稱:SocioBlood,代碼行數:30,代碼來源:VideoUploader.java


注:本文中的com.facebook.GraphRequest.executeAndWait方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。