当前位置: 首页>>代码示例>>Java>>正文


Java GraphRequest.Callback方法代码示例

本文整理汇总了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();
}
 
开发者ID:eviltnan,项目名称:kognitivo,代码行数:26,代码来源:ShareApi.java

示例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();
}
 
开发者ID:eviltnan,项目名称:kognitivo,代码行数:27,代码来源:Utility.java

示例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();
}
 
开发者ID:CE-KMITL-OOAD-2015,项目名称:Move-Alarm_ORCA,代码行数:24,代码来源:ShareApi.java

示例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;
}
 
开发者ID:JimRoid,项目名称:EasyFacebook,代码行数:24,代码来源:FacebookTool.java

示例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();
    }
}
 
开发者ID:agpyaephyo,项目名称:Movie-Maniac-Android,代码行数:27,代码来源:FacebookUtils.java

示例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();
    }
}
 
开发者ID:agpyaephyo,项目名称:Movie-Maniac-Android,代码行数:27,代码来源:FacebookUtils.java

示例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();
}
 
开发者ID:yudiandreanp,项目名称:SocioBlood,代码行数:26,代码来源:ShareApi.java

示例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));

    }
 
开发者ID:Dnet3,项目名称:CustomAndroidOneSheeld,代码行数:34,代码来源:FacebookShield.java

示例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);
}
 
开发者ID:simoneapp,项目名称:S3-16-simone,代码行数:8,代码来源:RealGraphRequestWrapper.java

示例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);
}
 
开发者ID:simoneapp,项目名称:S3-16-simone,代码行数:9,代码来源:AbstractGraphRequestWrapper.java

示例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);
}
 
开发者ID:simoneapp,项目名称:S3-16-simone,代码行数:8,代码来源:MockGraphRequestWrapper.java

示例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
        );
    }
 
开发者ID:seventhmoon,项目名称:PagesManager,代码行数:11,代码来源:GraphRequestHelper.java

示例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
        );
    }
 
开发者ID:seventhmoon,项目名称:PagesManager,代码行数:11,代码来源:GraphRequestHelper.java

示例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
    );
}
 
开发者ID:seventhmoon,项目名称:PagesManager,代码行数:10,代码来源:GraphRequestHelper.java

示例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();
}
 
开发者ID:CE-KMITL-OOAD-2015,项目名称:Move-Alarm_ORCA,代码行数:36,代码来源:ShareApi.java


注:本文中的com.facebook.GraphRequest.Callback方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。