6

I know there's a way to submit a link post to reddit.

https://www.reddit.com/r/test/submit?title=myTitle&url=http://www.exampledsfsd.com

which pops up a page like this with the title and url filled in

enter image description here

Is there a way to initiate the submission of a text post? It really just needs to get to the "text" tab and fill on the "text" field in this page

enter image description here

Just to be clear, I'm aware of the Reddit API. I don't want to take an approach that requires setting up a reddit account, a reddit app, and manage authentication for the user. I actually already tried this approach but there are issues with using it with other aspects of my site. I'm looking for something simple like the submit Link Post above

kane
  • 5,465
  • 6
  • 44
  • 72
  • I don't have a reddit account, but : What can you see when you "inspect" the submission button? You should be able to see some javascript performing an ajax request. Usually, you'll need to make a POST with the same parameters, including the login token – Luis Sieira Sep 05 '15 at 06:37
  • On the other hand, there is a Reddit API that you could find useful : http://stackoverflow.com/questions/11301342/reddit-submit-api-500-error?rq=1 – Luis Sieira Sep 05 '15 at 06:38
  • I believe that either reproducing what the submission button does on that page or using the Reddit API will require me to authenticate and authorize the user first. And I don't want to go down this route (i've already tried and there are other nuances that don't make sense for my site) – kane Sep 05 '15 at 06:50
  • You will need to authenticate the user anyhow, I cannot even see the form without logging in. – Luis Sieira Sep 05 '15 at 06:52
  • Possible duplicate of http://stackoverflow.com/questions/24823114/post-to-reddit-via-url?rq=1 – Luis Sieira Sep 05 '15 at 06:53
  • 1
    The reddit link submission I posted does not require authentication. I'm looking for a similar solution that does not require authentication – kane Sep 05 '15 at 06:56
  • 1
    I saw the SO but that's asking about posting links which I already know how to do. I'm looking for a way to post text – kane Sep 05 '15 at 06:57
  • In that case is strongly probable that that post request doesn't need it neither. Otherwise, I'm afraid I can't help here – Luis Sieira Sep 05 '15 at 07:03

2 Answers2

16

As CoderDennis said, you can use the submit page with the text parameter (urlencoded). You should also set selftext to true, which sets the displayed tab to the self post tab (although it's not required as that is inferred based off of the text parameter).

Some of the things in the doc for /api/submit still apply to that page (although only a few). You can see exactly how it works by looking at the code used for the actual page on reddit's GitHub (here and here)

For submitting a text post, what you'll want is a URL like this:

https://www.reddit.com/r/test/submit?title=Title%20to%20use&selftext=true&text=Urlencoded%20self%20post%20text

This will open the submit page for /r/test to submit a new post with the title "Title to use", and a post body of "Urlencoded self post text".

Here are all of the parameters, for reference:

  • title: Title of the post to submit
  • url: URL to submit to
  • text: Text of the self post
  • selftext: Whether to default to the self text tab (true to do so). If text is present, then it will default to displaying that tab anyways.
  • resubmit: Whether to resubmit the post (if not present and submitting a link post, and another post already links there, you will be taken to that post instead with an option to resubmit it).
Pokechu22
  • 4,984
  • 9
  • 37
  • 62
  • 1
    This answer should have gotten the bounty! – CoderDennis Sep 16 '15 at 20:45
  • What *exactly* does `selftext=true` do? I don't see any difference in the resulting page without it. – Dan Dascalescu May 30 '20 at 08:07
  • @DanDascalescu It tells it to use the text tab. It's implied by the `text` parameter, but e.g. `https://www.reddit.com/r/test/submit?title=Title%20to%20use` ( https://www.reddit.com/r/test/submit?title=Title%20to%20use ) will default to a link, but `https://www.reddit.com/r/test/submit?title=Title%20to%20use&selftext=true` ( https://www.reddit.com/r/test/submit?title=Title%20to%20use&selftext=true ) will default to text. (So, you need it if you want a link to submit a text post without putting text into the text field by default) – Pokechu22 May 31 '20 at 16:43
5

Simply guessed at this one, but it worked for me. Use text as the parameter instead of url.

https://www.reddit.com/r/test/submit?title=myTitle&text=testing

Of course, you'll need to url encode your text.

CoderDennis
  • 13,642
  • 9
  • 69
  • 105