Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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
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
add comment

1 Answer

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["http://twitter.com/home?status=" <> 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
add comment

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.