Reddit API
How do I make an reddit api?
Reddit posts without masonry. What is a reddit api? How do you make a reddit api? This script and codes were developed by Juan Vargas on 14 October 2022, Friday.
Reddit API - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Reddit API</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
<body>
<div class="container"> <h3>Display 100 Reddit Posts</h3>
<div id="posts"></div>
</div>
</body> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Reddit API - Script Codes CSS Codes
body { background:#f0f0f0; padding:0px; margin:0px; font-family:Arial; font-size:13px; color:#777;
}
ul li { list-style-type:circle;
}
h1,h2,h3,h4,h5 { padding:0px;
}
pre { white-space: pre-line;
}
p { line-height:25px; margin:0px;
}
a { cursor:pointer; text-decoration:none;
}
.menu { background:#2B3D4F; height:60px;
}
.menu ul { width:980px; margin:0px auto; padding:0px;
}
.menu ul li{ float:left; list-style:none; display:inline;
}
.menu ul li.right{ float:right; font-size:21px;
}
.menu ul li.right i{ color:gray;
}
.menu ul li.active a{ color:#FFF;
}
.menu ul li a{ height:60px; line-height:60px; padding:0 10px; display:block; color:#a2bdd9; text-transform:capitalize;
}
.menu ul li a:hover{ color:dodgerblue;
}
.container { width:600px; margin: 0 auto; margin-top:20px; position:relative; height;100%;
}
.container #posts .post { width:500px; margin: 0 18px 18px 0; float:left; padding:12px; background: #fff; border: solid 1px #ececec; border-radius:3px; float: left;
}
.container #posts .post.video { border-color:coral;
}
.container #posts .post.imgur { border-color:lightseagreen;
} .container #posts .post.thumbnail { border-color:dodgerblue;
}
.container #posts .post.self { border-color:orange;
}
.container #posts .post.API { border-color:red;
}
.container #posts .post img { max-width:100%;
}
.container #posts .post p{
line-height: 24px;
font-size: 14px;
color: #555;
font-weight: 400;
}
.container #posts .post img { max-width:100%;
}
.post span { padding: 10px; position: relative; left: -6px; bottom: -6px;
}
.info_bar { margin:0px; padding:0px; display:inline-block; width:100%; margin-top:10px;
}
.info_bar li,.info_bar a{ float:left; list-style:none; background: #eee; padding: 6px 8px; display: inline-block; color: grey; margin-right:5px; border-radius:2px;
}
.info_bar a.readmore{ background:lightseagreen; color:white;
}
.info_bar li span { margin-left:5px;
}
.info_bar li i { margin-right:6px;
}
.embedly-embed { width:280px; height:auto;
}
Reddit API - Script Codes JS Codes
//Retrieve Reddits for future filtering $.getJSON("http://www.reddit.com/reddits.json?jsonp=?&limit=10", function(data) { $.each(data.data.children, function(i, item) { var subs = $("<a>").attr("href", item.data.display_name).html(item.data.display_name); var list = $("<li class='subreddits'>").append(subs); $(".menu ul").append(list); }); }); //Get Subreddit Information $.getJSON("http://www.reddit.com/r/funny.json?jsonp=?&show=all&limit=100", function(data) { $.each(data.data.children, function(i, item) { //Retrieve Number of Comments var comments = $("<li>").html("<i class='fa fa-comments-o'></i>" + item.data.num_comments); //Retrieve author username var author = $("<p>").text(item.data.author); //Retrieve points var points = $("<li>").html("<i class='fa fa-arrow-up'></i>" + item.data.score); //Get Reddit Post paermalinks var permalink = $("<a class='readmore'>").attr("href", "http://www.reddit.com" + item.data.permalink).html("Read more"); //Get Reddit Post Titles var title = $("<p>").text(item.data.title); //Statistics bar var stats = $("<ul class='info_bar'>").append(points, comments, permalink); //Put link into image var images = $("<img/>").attr("src", item.data.url); //Create Thumbnail var thumbnail = $("<img/>").attr("src", item.data.thumbnail); //Pull post text content var body = $("<p>").html(item.data.selftext_html).text(); //Retrieve iframe embed content var embeded_content = $("<p>").html(item.data.media_embed.content).text();
IsValidImageUrl(item.data.url, function(url, isvalid) { if (isvalid) { var post = $("<div class='post'>").append(images, title, stats); $('#posts').append(post).masonry('appended', post) } else if (item.data.domain == "imgur.com") { //imgur API var clientId = "94330720455974e"; var imgurID = $('<a>', {href: item.data.url})[0].pathname.replace(/\.(.+)$/, ''); $.ajax({ url: 'https://api.imgur.com/3/image/' + imgurID, type: 'GET', beforeSend: function(request) {request.setRequestHeader('Authorization', 'Client-ID 94330720455974e');}, datatype: 'json', success: function(data) { var newimage = $("<img/>").attr("src", data.data.link); var newpost = $("<div class='post imgur'>").append(newimage, title, stats); $('#posts').append(newpost).masonry('appended', newpost) } }); } else if (item.data.secure_media.oembed.type == "video") { //Embed.ly API Key var key = '1ce631f8323d443094588475b2988052'; //Decode encoded URL var url_decode = decodeURIComponent(item.data.secure_media.oembed.thumbnail_url, key); //Remplace & with & var url_ready = $("<p>").html(url_decode).text(); //Get YouTube Thumbnail var video_thumbnail = $("<img/>").attr("src", url_ready); //Append image to box var thumbnail_post = $("<div class='post video'>").append(video_thumbnail,title,stats); //Display YouTube Video //var videopost = $("<div class='post'>").text(item.data.title).append(embeded_content).append(stats); $('#posts').append(thumbnail_post).masonry('appended', thumbnail_post); } else if (item.data.is_self == true) { var selfpost = $("<div class='post self'>").append(title, body, stats); $('#posts').append(selfpost).masonry('appended', selfpost) } else { var thumbpost = $("<div class='post thumbnail'>").append(title, thumbnail, stats); $('#posts').append(thumbpost).masonry('appended', thumbpost) } }); }); }); function IsValidImageUrl(url, callback) { var img = new Image(); img.onerror = function() { callback(url, false); }; img.onload = function() { callback(url, true); }; img.src = url; }
Developer | Juan Vargas |
Username | juanv911 |
Uploaded | October 14, 2022 |
Rating | 3 |
Size | 3,721 Kb |
Views | 14,168 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Tumblr API | 2,436 Kb |
Foursquare API - Search Places | 1,913 Kb |
Envato API | 3,337 Kb |
Unsplash API | 2,166 Kb |
SocialCounters - 17 Social Media APIs | 3,034 Kb |
Base | 2,606 Kb |
A Pen by Juan Vargas | 2,315 Kb |
Tumblr API - Tagged Posts | 2,096 Kb |
Navigation Menu | 2,839 Kb |
Question and Answer | 2,865 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Twitch.tv API | Ryzokuken | 2,618 Kb |
Stylize Stories | Jvhti | 2,465 Kb |
Pink expansion tunnel | Vez | 1,738 Kb |
Amazing CSS Menu with Notification Badges | Faizanasad | 2,549 Kb |
Responsive Section hover effect to show content | Berdejitendra | 2,540 Kb |
Opening Reveal Modal On Document Ready | Winghouchan | 1,787 Kb |
Mobile Sub Menu Concept | Berdejitendra | 2,790 Kb |
Pure CSS Tooltip | APinix | 2,815 Kb |
This in constructor context | _shree33 | 1,718 Kb |
Twinkling Stars | Ripley6811 | 2,750 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!