java - Facebook SDK 3.0 upload picture to a facebook page (not in album) -
hi noob @ android development trying implement feature allow user post message on facebook page option upload picture/image there device sd-card.
i using facebook sdk 3.0
i have managed make work not on facebook page wall, rather via users profile timeline.
thanks in advance.
*edit*
case request_pick_image: if (resultcode == result_ok) { imageuri = intent.getdata(); asyncfacebookrunner masyncfbrunner1 = new asyncfacebookrunner(mfacebook); log.d(tag, imageuri.tostring() + " " + imageuri.getpath()); bundle params = new bundle(); try { in = new fileinputstream(getrealpathfromuri(imageuri)); buf = new bufferedinputstream(in); byte[] bmaparray= new byte[buf.available()]; buf.read(bmaparray); params.putbytearray("picture", bmaparray); } catch (ioexception e) { e.printstacktrace(); } params.putstring("method", "photos.upload"); params.putstring("caption", "sample post via gallery"); masyncfbrunner1.request("page_id" + "/feed", params, "post", new photouploadlistener(), null); } break;
following code works me. using latest facebook sdk 3.0
showloader(getresources().getstring(r.string.sharing_on_facebook_wall)); request.callback callback= new request.callback() { public void oncompleted(com.facebook.response response) { hideloader(); facebookrequesterror error = response.geterror(); if (error != null) toast.maketext(getapplicationcontext(), error.geterrormessage(), toast.length_short).show(); else toast.maketext(getapplicationcontext(), "posted successfully.", toast.length_long).show(); } }; session session = session.getactivesession(); bundle postparams = new bundle(); postparams.putstring("name", "title"); postparams.putstring("link", "http://www.stackoverflow.com"); postparams.putstring("description", "description"); postparams.putstring("caption", "picturetestapp"); postparams.putstring("picture", imageurl); request request = new request(session, "me/feed", postparams, httpmethod.post, callback); requestasynctask task = new requestasynctask(request); task.execute();
Comments
Post a Comment