Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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]]
share|improve this question
4 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
up vote 8 down vote accepted

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["" <> hexEncode@ToString@expr];
Button["Share", sendTweet["Check this out! ", data]]
share|improve this answer
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.