当前位置: 首页>>代码示例>>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;未经允许,请勿转载。