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]]

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]]
  • $\begingroup$ That was the thing I was looking for, thanks! $\endgroup$ – István Zachar Apr 2 '12 at 13:27
  • $\begingroup$ it was a surprise to me that SystemOpen actually works within the CDF-Player -- good to know, thanks for that... $\endgroup$ – Albert Retey Apr 2 '12 at 16:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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