API discussion

Development-related discussion, including bundled plugins
nils.braden
Bear Rating Trainee
Bear Rating Trainee
Posts: 43
Joined: 25 Oct 2010, 12:12
Contact:

Re: API discussion

Postby nils.braden » 17 Jan 2011, 14:51

Hi fox,

Happy new year btw :)

I just finished implementing the offline-cache for images included in the content of articles and attachments and now need to fetch lots of articles. The caching is simply no use if you have to open all feeds by hand so the articles get cached and it is only afterwards you can start caching images for the articles.

The image-cache is supposed to make offline-browsing possible while "beeing on the road" and you can download all you need while you are on WIFI. So where do I get the articles? The current way is to call (deprecated) getNewArticles which probably only works for mysql databases (I think I saw some mysql-specific-calls there). You mentioned an RPC-API a while ago, do you think this is the way to do it? What would be the benefit of fetching articles this way in contrast to a normal API-call?

Greetings,
nils

edit: Just tried to fetch articles the normal way (fetch Headlines, then articles for this feed). Takes 2.5 minutes for 35 feeds :/

User avatar
fox
^ me reading your posts ^
Posts: 6318
Joined: 27 Aug 2005, 22:53
Location: Saint-Petersburg, Russia
Contact:

Re: API discussion

Postby fox » 18 Jan 2011, 12:19

Happy new year to you too! :)

Hmm... The RPC way is gone, I think I've cleaned it out of the code while removing Gears support. getNewArticles is quite messy and shares a lot of code with getArticles. Ideally, I'd like to drop both of them and replace them with some kind of less bloated unified method.

Ideally it should use api_get_headlines (since it has support for embedding article content anyway). Maybe add another parameter to output only articles newer than specific timestamp?

nils.braden
Bear Rating Trainee
Bear Rating Trainee
Posts: 43
Joined: 25 Oct 2010, 12:12
Contact:

Re: API discussion

Postby nils.braden » 18 Jan 2011, 12:49

That sounds good to me. As this function would basically return articles i'd suggest calling it getArticles but i fyou internally use getHeadlines that's fine too. At the moment output from getHeadlines is missing URL/CommentURL, Tags and Attachments, are these supposed to be in there or do you think that should be separated? Perhaps some parameter like "get_everything" could be added for content, urls and stuff so you would normally only get Headlines but this way you'd end up with full articles.

I would backup the idea of a timestamp for fetching articles. That would be useful to reduce the amount of articles. Currently I always fetch the latest 30 articles to make sure I don't miss any new articles but normally there are only a few so there is way too much bandwith used.

Greetings,
nils

nils.braden
Bear Rating Trainee
Bear Rating Trainee
Posts: 43
Joined: 25 Oct 2010, 12:12
Contact:

Re: API discussion

Postby nils.braden » 06 Feb 2011, 18:26

Hi,,

I stumbled accross an issue and would like to know if there is anything wrong with what I am doing there. Problem is, when calling login in a single_user_mode tt-rss instance there should be no username and password as far as I know. But login always returns API_DISABLED when called without arguments. Calling with username/password which were created while not beeing in singe_user_mode works like expected.

Don't know how to handle this in the client, should I request the setting for single_user_mode before logging in?

Greetings,
nils

User avatar
fox
^ me reading your posts ^
Posts: 6318
Joined: 27 Aug 2005, 22:53
Location: Saint-Petersburg, Russia
Contact:

Re: API discussion

Postby fox » 07 Feb 2011, 09:02

That's interesting. What if you try default username (e.g. admin)?

nils.braden
Bear Rating Trainee
Bear Rating Trainee
Posts: 43
Joined: 25 Oct 2010, 12:12
Contact:

Re: API discussion

Postby nils.braden » 07 Feb 2011, 12:55

With op=login&user=admin the login works, i get an SID. with empty username or empty username and empty password it returns API_DISABLED too.

User avatar
fox
^ me reading your posts ^
Posts: 6318
Joined: 27 Aug 2005, 22:53
Location: Saint-Petersburg, Russia
Contact:

Re: API discussion

Postby fox » 07 Feb 2011, 13:39

I suppose it should just use admin when in single user mode.

e.g. https://github.com/gothfox/Tiny-Tiny-RS ... 6e651b26b1

nils.braden
Bear Rating Trainee
Bear Rating Trainee
Posts: 43
Joined: 25 Oct 2010, 12:12
Contact:

Re: API discussion

Postby nils.braden » 07 Feb 2011, 15:56

Doesn't seem to work, I think the chek for single_user_mode needs to be before line 73 where the uid of the login-name is requested.

User avatar
fox
^ me reading your posts ^
Posts: 6318
Joined: 27 Aug 2005, 22:53
Location: Saint-Petersburg, Russia
Contact:

Re: API discussion

Postby fox » 07 Feb 2011, 16:25

Oh, right. Fixed in trunk. :)

nils.braden
Bear Rating Trainee
Bear Rating Trainee
Posts: 43
Joined: 25 Oct 2010, 12:12
Contact:

Re: API discussion

Postby nils.braden » 13 Apr 2011, 13:08


User avatar
fox
^ me reading your posts ^
Posts: 6318
Joined: 27 Aug 2005, 22:53
Location: Saint-Petersburg, Russia
Contact:

Re: API discussion

Postby fox » 13 Apr 2011, 14:30

First one should be simple enough to fix: https://github.com/gothfox/Tiny-Tiny-RS ... 44c809d0cb

I'm still not sure bulk loading stuff is the right thing to do things. I want to click on the feed I'm interested in and read it, not wait until it finishes hogging the wonky 3g connection loading random stuff that just happens to be unread. At this moment I don't even use tt-rss reader tbh, mobile version works way faster and it doesn't do any sort of preloading at all.

BTW there are two officially unsupported methods for the ttrss-reader in the API (getArticles/getNewArticles). Do you use them?

Maybe we need to rethink either the API or the way ttrss-reader works with it, since mobile version being faster doesn't make much sense in my opinion unless I have severely overbloated returned JSON.

nils.braden
Bear Rating Trainee
Bear Rating Trainee
Posts: 43
Joined: 25 Oct 2010, 12:12
Contact:

Re: API discussion

Postby nils.braden » 13 Apr 2011, 14:43


User avatar
fox
^ me reading your posts ^
Posts: 6318
Joined: 27 Aug 2005, 22:53
Location: Saint-Petersburg, Russia
Contact:

Re: API discussion

Postby fox » 13 Apr 2011, 14:59

Open the mobile/ subfolder. :)

nils.braden
Bear Rating Trainee
Bear Rating Trainee
Posts: 43
Joined: 25 Oct 2010, 12:12
Contact:

Re: API discussion

Postby nils.braden » 13 Apr 2011, 15:12

Oh.

Just a thought: What about putting this information somewhere on the main-information-site? :D
I did find just one reference to the mobile-version in Compatible Browsers and there it is only mentioned without explanation on where to find it. I fear this could make my users switch over to the mobile-version but that's not the point ;)

As for getArticles/getNewArticles, i don't use them because I wrote them and I know how bad my PHP-skills where at that time. And you told me not to use them. ^^
So you can safely remove them.

As for the app beeing slow and stuff, perhaps it doesn't really compete with a JavaScript based (it is, isn't it?) Website but it has the advantage of preloading stuff if you are going to be offline for some time or can't use mobile networks for some reason. I often start the ImageCache in the morning, then switch to offline-mode and leave for the bus...

edit: Hm, when I think about it...
Actually bulk-loading of articles is the one single difference to the mobile-website. Everything else can be easily achieved with JavaScript and a browser, only caching lots of articles for later offline-browsing cannot.

User avatar
fox
^ me reading your posts ^
Posts: 6318
Joined: 27 Aug 2005, 22:53
Location: Saint-Petersburg, Russia
Contact:

Re: API discussion

Postby fox » 13 Apr 2011, 15:34



Return to “Development”

Who is online

Users browsing this forum: No registered users and 1 guest