# How to embed “Share content” button into a CDF?

I want to have a button present in a CDF that, when pressed, shares some content material e.g. via Facebook. Is it possible or would the restrictions of the CDF format prevent anything from happening? Can it be done outside of CDF then? I don't have the slightest clue how to solve this... built-in? JLink? .NET/Link?

My ridiculously simple example code is this:

data = {"title", "URL", "summary", "image"};
Button["Share", shareOverFacebook[data]]

-
wolfram.com/cdf/faq/details-for-mathematica-programmers.html clarifies that JLink and NETLink and MathLink are banned. –  Rolf Mertig Mar 31 '12 at 0:17
Perhaps this question about getting data out of CDF player may be useful. –  Sjoerd C. de Vries Mar 31 '12 at 9:02

## 1 Answer

For short textual content, you can always use SystemOpen on a crafted URL. For example, the code below works in CDF and allows you to embed content in a tweet (sorry, I don't know the facebook API, so I went with this instead!):

hexEncode[s_String] :=
StringJoin@Riffle[IntegerString[ToCharacterCode[s, "UTF-8"], 16, 2], "%", {1, -2, 2}];
sendTweet[text_, expr_] :=
SystemOpen["http://twitter.com/home?status=" <> hexEncode@ToString@expr];
Button["Share", sendTweet["Check this out! ", data]]

-
That was the thing I was looking for, thanks! –  István Zachar Apr 2 '12 at 13:27
it was a surprise to me that SystemOpen actually works within the CDF-Player -- good to know, thanks for that... –  Albert Retey Apr 2 '12 at 16:25