如何才能从与API墙Android应用的Facebook不检查升贴?(How can l post

2019-10-18 07:32发布

怎样才能升贴在从API墙Android应用的Facebook不检查(显示“涂鸦墙”从Facebook屏)

Answer 1:

只需拨打publishStory(StringYouNeed,StringYouNeed,StringYouNeed); 而在你的活动/片段实现这一点:

private void publishStory(String hash, String title, String user) {

    Session session = Session.getActiveSession();

    if (session != null){
        // Check for publish permissions    
        List<String> permissions = session.getPermissions();
        if (!isSubsetOf(PERMISSIONS, permissions)) {
            pendingPublishReauthorization = true;
            Session.NewPermissionsRequest newPermissionsRequest = new Session
                    .NewPermissionsRequest(getActivity(), PERMISSIONS);
            session.requestNewPublishPermissions(newPermissionsRequest);
            return;
        }
        Bundle postParams = new Bundle();
        postParams.putString("name", title);
        postParams.putString("caption", "bla bla");
        postParams.putString("description", "bla bla");
        postParams.putString("link", "http://blabla.com/"+hash);

        Request.Callback callback= new Request.Callback() {
            public void onCompleted(Response response) {
                JSONObject graphResponse = response
                        .getGraphObject()
                        .getInnerJSONObject();
                String postId = null;
                try {
                    postId = graphResponse.getString("id");
                } catch (JSONException e) {
                    Log.i(TAG,
                            "JSON error "+ e.getMessage());
                }
                FacebookRequestError error = response.getError();
                if (error != null) {
                    debug.print("erreur");
                } 
            }
        };

        Request request = new Request(session, "me/feed", postParams, 
                HttpMethod.POST, callback);

        RequestAsyncTask task = new RequestAsyncTask(request);
        task.execute();
    }

}
private boolean isSubsetOf(Collection<String> subset, Collection<String> superset) {
    for (String string : subset) {
        if (!superset.contains(string)) {
            return false;
        }
    }
    return true;
}

完美的作品对我来说,希望这帮助。



Answer 2:

波纹管教程帮你做到这一点

http://www.integratingstuff.com/2010/10/14/integrating-facebook-into-an-android-application/



Answer 3:

创建您的网页,并给一个链接

// use this function
private void shareToFacebook() {

    // add urlToShare to your own site url
    String urlToShare = "http://mithsoft.net/home/";
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_TEXT, urlToShare);

   // See if official Facebook app is found
    boolean facebookAppFound = false;
    List<ResolveInfo> matches = getPackageManager().queryIntentActivities(intent, 0);
    for (ResolveInfo info : matches) {
        if (info.activityInfo.packageName.toLowerCase().startsWith("com.facebook.katana")) {
            intent.setPackage(info.activityInfo.packageName);
            facebookAppFound = true;
            break;
        }
    }
   // As fallback, launch sharer.php in a browser
    if (!facebookAppFound) {
        String sharerUrl = "https://www.facebook.com/sharer/sharer.php?u=" + urlToShare;
        intent = new Intent(Intent.ACTION_VIEW, Uri.parse(sharerUrl));
    }
    startActivity(intent);
}


文章来源: How can l post on facebook from android app with API wall without checking?