Posting text and image to my Facebook 'wall' from Codenameone app - facebook

What I am trying to do from my Codenameone app, in Eclipse, is to send a piece of Text and an Image to my Facebook wall. Simple (or is it). Can anyone explain to me how to achieve this in Java (in a CN1 app) please?
I am not wanting the user to login to facebook in my app. Instead, to achieve this in the same way that many mainstream apps do this (eg. BBC News app) where they use the Facebook app, that is already installed on the device, in the list of destinations to Share to, which resolves the FaceBook connection issue. If the user doesn't have FB app installed then I will not make this available to them.
I have read articles online but they are a number of years old (post out of date) or make use of tokens (for which I have little knowledge how to implement).
Assuming the above is possible then any information on formatting the destination post would be a real plus.
Many thanks in advance.

Answered by #WizKid, #Diamond, #Shai Almog.
I have put a ShareButton component on my screen allowing the user share with FB, Twitter etc.
ShareButton sb = new ShareButton();
sb.setUIID("Label");
sb.getAllStyles().setAlignment(Component.TOP);
String imageFile = FileSystemStorage.getInstance().getAppHomePath() + getMyFileName();
sb.setImageToShare(imageFile, "image/png");
sb.setTextToShare("My Text to share");
This works nicely, although its doesn't put the text from my setTextToShare() into FB but does Twitter and Email. Strange. Photo goes up and it does allow me to type my own text in.

Related

Codenameone ShareButton - Sharing URL and Image content to Facebook

I have a Codenameone ShareButton in my app, when pressed opens a dialog containing a list of the standard social media apps, that i have on my device, eg. Facebook, SMS, Email, Twitter.
I am trying to get a combination of text, image and URL into the ShareButton dialog for Facebook, but failing. It seems to work for the other types of media. I have scoured StackOverflow without luck on this one.
I can share an image to facebook successfully:
ShareButton sb = new ShareButton();
sb.setImageToShare(imageFile, "image/png");
I can share a URL to facebook successfully:
ShareButton sb = new ShareButton();
sb.setTextToShare("www.mywebsite.co.uk");
My goal is to share a piece of text, a URL and an image to facebook (which i can do to other media). My issues are:
Text wont display in the facebook app dialog:
ShareButton sb = new ShareButton();
sb.setTextToShare("The text i want to display");
I have seen conflicting posts over the years about FB support for this, so maybe i'm doomed on this one.
I tried to trick it and prefix or suffix text to the URL but this didn't display that text still.
So I want to display an image and a URL in the post to FB and it really is just one or the other it seems. So the code below will display just the URL on its own in the FB dialog without the image (swapping out the URL for regular text, displays the image and no text):
ShareButton sb = new ShareButton();
sb.setImageToShare(imageFile, "image/png");
sb.setTextToShare("www.mywebsite.co.uk");
I'd be happy with just option 2 if needs be.
To be clear i'm using the facebook app on my device to share and not a token connection direct to facebook.
And if it helps i do have my own website, if there was a way to send it content and it dynamically build up the content for display, but that may not be possible (i'm no web developer).
As far as I recall from the last time I was dealing with posting to facebook, they don't allow you to post both an image and text, or a URL and text together. If you want to have something show up in the user's feed that includes both an image and a description, you'll need to create a web page that includes Facebook's supported Open Graph markup, which will cause it to be displayed "nicely" in the user's feed.
In projects I have worked on in the past, they used dynamic webpages so that it was easy to create a webpage that was specific to the content you want to post in the user's feed. You can essentially generate a separate webpage for each "share" if necessary.
We used the feed API directly. I'm not sure if it works from the share button, but if you were able to post a URL, then it probably works.

&makeprofile=1 parameter no longer works

I made several apps that invited the user to create pictures, uploaded them to facebook and then sent them to a link on facebook that allowed them to set them as their profile picture:
https://www.facebook.com/photo.php?fbid=10152753169290428&makeprofile=1
In the last few days, facebook is just ignoring the makeprofile parameter. I just love developing for facebook, it's such a roller coaster ride.
Can anyone help? Is there an alternative?
You can redirect to the mobile URL like:
http://m.facebook.com/photo.php?fbid=[photo-id]&prof
and then it magically works.
The undocumented makeprofile=1 does still work, but the user needs to have permission to view the photo in the first place. I tested this on the following public image:
https://www.facebook.com/photo.php?fbid=10100464869430336&set=a.575724691546.2154239.60506094&type=1&makeprofile=1
Update (14 Dec 2014):
Clicking on the above link using a Desktop browser shows me the below popup on Facebook. The feature does still work (at least for me).

Share image including some attributes (e.g. description) on Facebook over web without app validation hassle

I want to share an image from a website on Facebook and pass some attributes (e.g. a description) to the status update, all done by clicking on a link.
A few months ago this worked fine using the sharer.php but by now this script just accepts a URL as parameter and scrapes the target site for Open Graph meta tags. This new approach isn't very helpfull if you just want to share elements on a page instead of the whole page.
Yeah, I could create an app and use the feed dialog to achieve my goal. But I honestly don't want to walk through the tedious app validation process just to share an image with some additional info!
So, does anyone know of a way to avoid this app hassle? Perhaps some undocumented parameters for the new implementation of the sharer.php?
There's no need for app validation - as #CBroe correctly stated! So the feed dialog IS an adequate solution!
Background: I assumed an app needs validation to go live. But I just didn't set up my app properly to make it available to every Facebook user.
See the comments to gloat over my stupidity. ;)

Multiple Facebook share button/link on the same page refering different TITLE & LINK

I need to create a "contest" page where user will be asked to submit picture.
After that, they should be able to share their picture on FB, Twitter, G+, Pinterest, etc for other people to come and vote.
I want the page to be displayed as a jQuery gallery and whenever people select a thumbnail, the bigger picture open with the associated vote and "share" button.
When a user share an image, I want a specific TITLE & URL associated with that particular image... something like "http://www.mysite.com/contest.html#picture1"... or "http://www.mysite.com/contest.html#picture2"
How is this possible if I only have one page?
I wouldn't have problem if I could use the old "facebook.com/sharer.php" with parameters... but it seems that the Open Graph Protocol is "overiding" the sharer.php parameters....
Works fine with Twitter and Pinterest... I might have the same problem with Google+.
Excuse my bad english, thanks!
Well, set up a (“dummy”) page for each picture, and fill it with the appropriate OG tags … and have your users like that. And then put a JS redirect into that page, so that users following the link when it’s shared on Facebook will get to the “real” address you want them to end up at.
(Btw., IMHO this is what happens too often these days when people think doing everything client-side and client-side only is so “fancy” and that a “good” and “modern” site requires all that AJAX/one-page-only nonsense instead of a real good and working URL structure, and then are not able to handle all that this implies properly …)

Creating a Facebook App

I am building a website for a client. He has a Facebook page for his business. On the homepage of his site, he wants a feed that will pull in all the updates from his business' Facebook page.
Now, I felt this would be very easy to implement (maybe it is) but I have scoured the Facebook API for any simple way to do this. I am having a lot of trouble understanding which way I should do this. I've settled on using JS to access it, but have no idea where to go from there.
Do I need to create an app? If so, which options do I select so I can access the clients facebook page?
How do I get my app that I've created to show up so a user can authorize it? I have so many questions, and Facebook isn't very good at giving me answers.
Any help is greatly appreciated.
I would suggest you just use the facebook page's RSS feed.
Example
Take his page URL e.g.
https://www.facebook.com/pages/Lazery-Attack/6001014870
Take the number at the end of the url off, and plug it into the facebook feeds URL e.g.
https://www.facebook.com/feeds/page.php?format=rss20&id=6001014870
Voila, you now have an RSS feed you can integrate into the website you are building.
URL Breakdown
The URL is broken down the following way:
https://www.facebook.com/feeds/page.php?format={feedFormat}&id={PageID}
Vaid feed formats are:
RSS - rss20
Atom - atom10
JSON - json
Other Examples
Atom
https://www.facebook.com/feeds/page.php?format=atom10&id=6001014870
JSON
https://www.facebook.com/feeds/page.php?format=json&id=6001014870
Take a look at the facebook API, right here: http://developers.facebook.com/docs/reference/api/page/
You can give it a try here:
http://developers.facebook.com/tools/explorer/?method=GET&path=19292868552%2Fposts
The like box: http://developers.facebook.com/docs/reference/plugins/like-box/ also has the latest posts available
The simplest way is to add a Like Button to the page and make sure "show Stream" is checked on as this will show all recent posts. You can customise the appearance also (e.g. width, height etc).
No App or messy API calls needed!
Try it out here and simply paste the resulting code into your webpage:
http://developers.facebook.com/docs/reference/plugins/like-box/
Not an app, but the Facebook Social Plugins over here at Facebook For Pages