8
\$\begingroup\$

A short while, ago, @daniel_ernston sent the following challenge to @StackCodeGolf on Twitter:

@StackCodeGolf Your task is to build a program that uses the API of your choice to tweet its own source code. Shortest code wins, of course.

\$\endgroup\$
6
  • 1
    \$\begingroup\$ What about reading the source code and other quine cheats? \$\endgroup\$ Commented Mar 7, 2015 at 3:06
  • \$\begingroup\$ All permissible. I want to see how short you can get it, and I have a suspicion it may not be possible if I don't open those up. \$\endgroup\$
    – Joe Z.
    Commented Mar 7, 2015 at 3:08
  • \$\begingroup\$ If you can come up with a solution that doesn't use that cheat, though, then by all means I'll give you an honourable mention (and maybe even a bounty). \$\endgroup\$
    – Joe Z.
    Commented Mar 7, 2015 at 3:08
  • \$\begingroup\$ Hm, won't this depend quite heavily on the chosen user name and credentials? (Both whether it fits in the tweet and the actual score.) \$\endgroup\$ Commented Mar 7, 2015 at 3:15
  • 13
    \$\begingroup\$ I don't have a twitter account and while I could create one, I have to give them my phone number to get an api key, maybe someone could post api keys from a throwaway account for everyone to use. This would also make the challenge fairer since they would be the same length. \$\endgroup\$
    – Maltysen
    Commented Mar 8, 2015 at 19:25

2 Answers 2

10
\$\begingroup\$

JavaScript, 38 characters

window.open("http://tinyurl.com/erjk34");

Here is the tweet, in all its glory: https://twitter.com/kevinaworkman/status/575425948562014209

And here is my previous entry at 95 characters:

function q() {
window.open("https://twitter.com/intent/tweet?text="+encodeURIComponent(q+";{q();}"));
};{q();}

And if that's not cheating...

HTML, 22 characters

http://tinyurl.com/erjk35

\$\endgroup\$
19
  • \$\begingroup\$ It this what was meant by tweeting or was it referring to the REST API dev.twitter.com/rest/public? \$\endgroup\$
    – Maltysen
    Commented Mar 10, 2015 at 20:51
  • \$\begingroup\$ @Maltysen It sends a tweet, so I'm counting it as fair game. It might be cheating, but hey, OP said that cheating was allowed! :p \$\endgroup\$ Commented Mar 10, 2015 at 20:56
  • 1
    \$\begingroup\$ Okay then, +1 for loopholes. \$\endgroup\$
    – Maltysen
    Commented Mar 10, 2015 at 21:05
  • 1
    \$\begingroup\$ Well, uh, the TinyURL should post the tweet entirely by itself, without requiring you to press the "Tweet" button... \$\endgroup\$
    – Joe Z.
    Commented Mar 10, 2015 at 23:48
  • 1
    \$\begingroup\$ @JoeZ. I went into this knowing that it was probably cheating- especially my last update, haha. I just figured it would be fun to try, especially since you didn't have any answers after 3 days! \$\endgroup\$ Commented Mar 11, 2015 at 0:00
0
\$\begingroup\$

Python 2, 118 bytes

import webbrowser,urllib
webbrowser.open("https://twitter.com/intent/tweet?text="+urllib.quote(open(__file__).read()))

(Can't) Try it online! (Run locally)

¯\_(ツ)_/¯

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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