Skip to content Skip to sidebar Skip to footer

How Can L Post On Facebook From Android App With Api Wall Without Checking?

How can l post on facebook from android app with API wall without checking (displaying 'post to wall' screen from facebook)

Solution 1:

Just call publishStory(StringYouNeed,StringYouNeed,StringYouNeed); And implement this in your activity / Fragment :

privatevoidpublishStory(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 = newSession
                    .NewPermissionsRequest(getActivity(), PERMISSIONS);
            session.requestNewPublishPermissions(newPermissionsRequest);
            return;
        }
        Bundle postParams = newBundle();
        postParams.putString("name", title);
        postParams.putString("caption", "bla bla");
        postParams.putString("description", "bla bla");
        postParams.putString("link", "http://blabla.com/"+hash);

        Request.Callback callback= newRequest.Callback() {
            publicvoidonCompleted(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 = newRequest(session, "me/feed", postParams, 
                HttpMethod.POST, callback);

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

}
privatebooleanisSubsetOf(Collection<String> subset, Collection<String> superset) {
    for (Stringstring : subset) {
        if (!superset.contains(string)) {
            returnfalse;
        }
    }
    returntrue;
}

Works perfect for me, hope this help.

Solution 2:

Solution 3:

Create your web page and give a link

// use this functionprivatevoidshareToFacebook() {

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

   // See if official Facebook app is foundbooleanfacebookAppFound=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 browserif (!facebookAppFound) {
        StringsharerUrl="https://www.facebook.com/sharer/sharer.php?u=" + urlToShare;
        intent = newIntent(Intent.ACTION_VIEW, Uri.parse(sharerUrl));
    }
    startActivity(intent);
}

Post a Comment for "How Can L Post On Facebook From Android App With Api Wall Without Checking?"