How can I post text only to my Facebook wall in Android? -


currently, using following code:

bundle params = new bundle(); //params.putstring("message", "i want post text only."); params.putstring("name", "facebook sdk android"); params.putstring("caption", "build great social apps , more installs."); params.putstring("description", "description"); params.putstring("link", "https://developers.facebook.com/android"); params.putstring("picture", "https://raw.github.com/fbsamples/ios-3.x-howtos/master/images/iossdk_logo.png");  webdialog feeddialog = (     new webdialog.feeddialogbuilder(getactivity(),         session.getactivesession(),         params))     .setoncompletelistener(new oncompletelistener() { 

however, can't post message only, because bundle must include "link".

here complete solution.please try out,i using code , works fine. if not logged in( if using first time) direct login screen (else) , access token got stored in local data.after allowed share text facebook wall.

if (facebook.getaccesstoken() != null) {              postonwall("msg share");          } else {             logintofacebook();              }  public void postonwall(string msg) {     log.d("tests", "testing graph api wall post");     try {         string response = facebook.request("me");         bundle parameters = new bundle();          parameters.putstring("message", msg);         parameters.putstring("description", "test test test");         // parameters.putbytearray("message", msg);         response = facebook.request("me/feed", parameters, "post");         log.d("tests", "got response: " + response);         if (response == null || response.equals("")                 || response.equals("false")) {             log.v("error", "blank response");              toast.maketext(getapplicationcontext(), "facebookerror",toast.length_short).show();          }     } catch (exception e) {         e.printstacktrace();      } }  public void logintofacebook() {      mprefs = getpreferences(mode_private);     string access_token = mprefs.getstring("access_token", null);     long expires = mprefs.getlong("access_expires", 0);      if (access_token != null) {         facebook.setaccesstoken(access_token);          log.d("fb sessions", "" + facebook.issessionvalid());     }      if (expires != 0) {         facebook.setaccessexpires(expires);     }      if (!facebook.issessionvalid()) {         facebook.authorize(this,                 new string[] { "email", "publish_stream" },                 new dialoglistener() {                      @override                     public void oncancel() {                         // function handle cancel event                     }                      @override                     public void oncomplete(bundle values) {                         // function handle complete event                         // edit preferences , update facebook acess_token                         sharedpreferences.editor editor = mprefs.edit();                         editor.putstring("access_token",                                 facebook.getaccesstoken());                         editor.putlong("access_expires",                                 facebook.getaccessexpires());                         editor.commit();                         toast.maketext(sms_by_id.this,                                 "successfully login", toast.length_long)                                 .show();                         pwindo.dismiss();                          // making login button invisible                      }                      @override                     public void onerror(dialogerror error) {                         // function handle error                      }                      @override                     public void onfacebookerror(facebookerror fberror) {                         // function handle facebook errors                         pwindo.dismiss();                         toast.maketext(sms_by_id.this, "facebook error",                                 toast.length_long).show();                     }                  });     } } 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -