@Override public void post( final Activity parent, String appId, String linkName, String message, String link, String caption, final SocialNetworkListener listener) { Bundle params = new Bundle(); params.putString("name", linkName); params.putString("message", message); params.putString("link", link); params.putString("caption", caption); Facebook fb = newFacebook(appId); final FacebookSessionStore store = newFacebookSessionStore(); store.restore(fb, parent); AsyncFacebookRunner runner = newAsyncFacebookRunner(fb); RequestListener requestListener = newRequestListener(parent, listener); runner.request("me/feed", params, "POST", requestListener, null); }
@Override public void postPhoto( Activity parent, String appId, String link, String caption, Uri photoUri, SocialNetworkListener listener) { try { Bundle params = new Bundle(); params.putString("caption", caption + ": " + link); params.putByteArray("photo", facebookImageUtils.scaleImage(parent, photoUri)); Facebook fb = newFacebook(appId); final FacebookSessionStore store = newFacebookSessionStore(); store.restore(fb, parent); AsyncFacebookRunner runner = newAsyncFacebookRunner(fb); RequestListener requestListener = newRequestListener(parent, listener); runner.request("me/photos", params, "POST", requestListener, null); } catch (IOException e) { if (listener != null) { listener.onError(parent, SocialNetwork.FACEBOOK, "Unable to scale image for upload", e); } if (logger != null) { logger.error("Unable to scale image for upload", e); } else { e.printStackTrace(); } } }