reddit

Format \n\n into \n and disable unique \n in PHP (a la reddit)

最后都变了- 提交于 2019-12-23 03:11:09
问题 I'm looking to do the same thing for my website as I've seen on reddit. When you \n once, it will not work, you will have to do two \n\n to get one I tried this : $texte = preg_replace('#{\n}#', '', $texte); $texte = preg_replace('#{\n}{\n}#', '\n', $texte); $texte = nl2br($texte); and it doesn't work... someone can help? 回答1: Try this: $texte = preg_replace('#(\r\n|\r)#', "\n", $texte); $texte = preg_replace('#\n(?!\n)#', ' ', $texte); $texte = preg_replace('#\n\n#', "\n", $texte); $texte =

Reddit integration to android app

丶灬走出姿态 提交于 2019-12-23 02:08:07
问题 I need to integrate Reddit to android app. I don't need much. Only log in and post a new link. (something like a share on Facebook). But I am struggling on the very beginning. Any help will b appreciated. EDIT: Here is what I made so far, I get the modhash and captcha but when I try to submit new link it gives me this: {"json": {"errors": [["USER_REQUIRED", "please login to do that", null]]}} private void getModhash(){ modhash = dbHandler.getUserModahash(); if(modhash.equals("")){ String

Reddit API returns HTTP 403

人盡茶涼 提交于 2019-12-22 08:36:50
问题 Following the OAuth2 login flow described at https://github.com/reddit/reddit/wiki/OAuth2 I got to the point where POST-ing to https://www.reddit.com/api/v1/access_token returns something like this: {'token_type': 'bearer', 'expires_in': 3600, 'scope': 'identity', 'access_token': '*****'} Then I do GET https://oauth.reddit.com/api/v1/me With this header: Authorization: bearer ***** The response is HTTP 403 Unauthorized. But why? It is clear that the access token has 'identity' scope. It is

Angular - Correctly using RXJS expand operator to make recursive http calls

柔情痞子 提交于 2019-12-19 04:24:20
问题 I am attempting to make recursive http calls to Reddit's API using a value from the previous call. The problem is that the previous call is not finished before the next one starts, so duplicate calls are being made. The "after" value should be updated for every call until the "after" value is undefined. I found this related post and have attempted to use the solution described, but I can't figure out how to make sure the previous call is finished before making the next call. Below is my

How to extract url data from Reddit API using JSON

夙愿已清 提交于 2019-12-17 10:46:36
问题 I'm trying to extract the image post URLs from a subreddit feed, and render <img> elements on my page. Been trying to hack together the .getJSON() Flickr example from the jQuery Docs for a while now and I'm not getting anywhere. Code in question: $.getJSON('http://www.reddit.com/r/pics.json', function (data) { $.each(data.children, function (i, item) { $('<img/>').attr("src", url).appendTo("#images"); }); }); In the body, I have the element: div#images I understand that I need to use JSONP,

Download file from Django Project root using a button

假装没事ソ 提交于 2019-12-13 17:19:32
问题 So, this is the webpage I'm creating atm with Django 1.8: Want the user to be able to export the data as .csv. When the user: writes a subreddit name in the box presses the button 'Get Data' What happens: it's created a test.csv (saved in the root of the project) data is retrieved using Praw data is inserted into the .csv data is rendered for the users to see The problem now is: I want the button with 'Export to Excel', to download the generated file from the root of the Django project. This

Getting & instead of & in title return using PRAW

时光总嘲笑我的痴心妄想 提交于 2019-12-13 17:10:02
问题 I'm trying to get the top 25 of all time of a given subreddit using PRAW: import praw subreddit = 'gamedeals' r = praw.Reddit(user_agent='getting top 25 of all time by /u/sqrg') submissions = r.get_subreddit(subreddit).get_top_from_all(limit=25) titlesFile = open("text.txt", 'w') for s in submissions: titlesFile.write(s.title.encode('utf-8', 'replace') + '\n') titlesFile.close() I get the following error: UnicodeEncodeError: 'ascii' codec can't encode character u'\xa3' in position 63: ordinal

How to get access token? (Reddit API)

a 夏天 提交于 2019-12-13 11:36:11
问题 I wonder if it is possible to get a permanent access token for personal use on Reddit? It will only be me using the App. For users, the access token expires after 1 hour. My using the below information that I have about my client-id and secret, I put up a start attempt of trying to get an access token. (MessageBox show " Error 401 ") If a user will get a token, one have to click "Allow" in the browser. Very well described here. https://github.com/reddit/reddit/wiki/OAuth2 This it NOT what I

403 error when trying to get data from Reddit API

不羁岁月 提交于 2019-12-13 07:26:40
问题 I am using oAuth to authenticate my app. I managed to get a code, access_token and refresh_token. So the next step would be trying to get info about the current user. public async void GetCurrentUser() { using (var client = new HttpClient()) { client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", AccessToken); var response = await client.GetAsync("https://oauth.reddit.com/api/v1/me"); if (response.IsSuccessStatusCode) { var json = await

Decoding JSON from Reddit API in Python using PRAW

你离开我真会死。 提交于 2019-12-12 16:15:48
问题 I am using PRAW for Reddit API in a Python/GTK application. I have been successful in using the API, but I can't seem to be able to decode the JSON for use. It should be known that I am a beginner in Python and GTK applications. # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- ### BEGIN LICENSE # This file is in the public domain ### END LICENSE import gettext from gettext import gettext as _ gettext.textdomain('redditreader') from gi.repository import Gtk # pylint: