I've become very frustrated attempting to post a google chart image to the facebook me/feed.
The cart image is dynamically created by a potentially very long URL.
I'm able to set that URL in the "picture" key in the bundle, but if I attempt to place it in the "link" key, I get an error that it is too long.
If I only pass in a "picture" the thumbnail on the feed is always blank.
I tried to remedy this problem by converting the URL to a tinyurl, except that facebook always appends ?ref=nf to the end of the tinyurl and breaks it (404 error when you click on it, however, the image is visible in the thumbnail). I found this thread with other users having this problem:
http://forum.developers.facebook.net/viewtopic.php?id=40469
Here is my code:
private void updateFacebookStatusImage()
{
String accessToken = FBSessionStore.getToken(this);
Bundle bundle = new Bundle();
bundle.putString("caption", this.fbUserComment);
bundle.putString("description", this.fbMessage);
try
{
String tiny = BetBudHttpRequestor.getTinyUrl(this.fbImageURL);
Log.d("IMAGE", tiny);
bundle.putString("picture", tiny);
bundle.putString("link", tiny);
}
catch (ClientProtocolException e)
{
}
catch (IOException e)
{
}
bundle.putString(Facebook.TOKEN, accessToken);
fbAsyncRunner.request("me/feed", bundle, "POST", new UpdateWallListener(), null);
this.fbMessage = null;
this.fbUserComment = null;
this.fbImageURL = null;
}
Here is a sample google chart URL:
http://chart.apis.google.com/chart?chf=bg,s,000000&chxt=x,y&chs=480x340&cht=lxy&chco=696969,E8EEF7&chls=3|3&chxl=0:|03:01+1ST|09:22+2ND|04:25+2ND|08:55+3RD|01:24+3RD|09:28+4TH|03:35+4TH|FINAL&chd=t:70|0,0,8,8,13,13,13,13,15,15,17,17,17,17,17,17,23,23,23,23,23,23,23,23,25,25,27,27,29,29,34,34,36,36,40,40,45,45,46,46,49,49,51,51,51,51,56,56,58,58,58,58,62,62,62,62,65,65,69,69,73,73,77,77,78,78,87,87,90,90|70|2,2,6,6,8,8,10,10,14,14,18,18,20,20,21,21,24,24,26,26,31,31,33,33,33,33,37,37,37,37,42,42,42,42,46,46,50,50,52,52,57,57,59,59,65,65,69,69,72,72,74,74,76,76,78,78,80,80,84,84,86,86,92,92,97,97,103,103,105,105&chdlp=b&chdl=Memphis|Oklahoma+City&chxr=1,0,105&chds=0,71,0,105,0,71,0,105&chm=B,4169e1,0,0:4,0|B,00FF00,0,4:6,0|B,4169e1,0,6:20,0|B,ffa500,0,20:32,0|B,4169e1,0,32:40,0|B,ffa500,0,40:64,0|B,FF0000,0,64:66,0|B,ffa500,0,66:68,0|B,FF0000,0,68:69,0
...and the tinyurl:
http://tinyurl.com/3jnhp3k
I'd like to avoid having to upload the generated chart to flikr if I can, but I'm thinking this may be my only hope. I'm hoping some of you brilliant minds out there may have a suggestion?
To recap:
If I post the full url to only the picture key:
When you click the thumbnail, the image loads, however, the thumbnail is empty.
If I post the tinyurl to the picture, or the picture and link:
The thumbnail has the image, but the link is broken because of ?ref=nf.
Thanks, Steve
Use a different url shortener service like bit.ly. I doubt Facebook is going to stop appending the referral source to links, so services and websites need to be able to properly handle querystring parameters. If anything, you could log a bug with tinyurl. Here is the bit.ly link I generated for you and it works: