Skip to content
This repository was archived by the owner on Jun 27, 2020. It is now read-only.
This repository was archived by the owner on Jun 27, 2020. It is now read-only.

Can't request the "SEEN IT" section with #search + link. #21

@siers

Description

@siers

So, if you put a link into the reddit's search box, then it will show you where has that link already been submitted. It will redirect to /submit?url=your_url. Now, RedditKit doesn't do redirects.

With this code, it does:

module RedditKit
  class Client
    def middleware
      @middleware ||= Faraday::Builder.new do |builder|
        builder.use Faraday::Request::UrlEncoded
        builder.use RedditKit::Response::RaiseError
        builder.use RedditKit::Response::ParseJSON
        # *These two lines below allow the redirects to happen.*
        builder.use FaradayMiddleware::FollowRedirects
        builder.adapter :net_http
      end
    end
  end
end

And without the redirects, client.search('http://www.youtube.com/watch?v=XAAgXaMCdfI') just returned nil. Now, it returns nil only when it hasn't been submitted, a listing otherwise.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions