You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
1.1 KiB
Java

3 years ago
package sh.adb.RandomRedditMemesAPI;
3 years ago
import com.github.jreddit.oauth.RedditOAuthAgent;
import com.github.jreddit.oauth.RedditToken;
import com.github.jreddit.oauth.app.RedditApp;
import com.github.jreddit.oauth.app.RedditInstalledApp;
import com.github.jreddit.oauth.exception.RedditOAuthException;
3 years ago
import com.sun.net.httpserver.HttpServer;
3 years ago
import org.json.simple.parser.ParseException;
3 years ago
import java.io.IOException;
import java.net.InetSocketAddress;
3 years ago
public class Main {
3 years ago
public static void main(String[] args) throws IOException, RedditOAuthException, ParseException {
3 years ago
HttpServer server = HttpServer.create(new InetSocketAddress(8000), 0);
3 years ago
server.createContext("/", new FallbackHandler());
//server.createContext("/api/v1/", new StandardHandler());
server.createContext("/api/v1/r/", new CommunityHandler());
3 years ago
server.setExecutor(null);
server.start();
3 years ago
System.out.println("server started");
RedditAPI client = new RedditAPI();
System.out.println("the token is");
3 years ago
System.out.println(client.token.getAccessToken());
3 years ago
}
}