How to use cURL to call the API

Howtos, instructions and links to related software. Do not ask questions here.
redheadkelly
Bear Rating Trainee
Bear Rating Trainee
Posts: 11
Joined: 05 Apr 2013, 11:50

How to use cURL to call the API

Postby redheadkelly » 05 Apr 2013, 11:59

Can someone please dumb down the API instructions for me? I've never used cURL & everything I know of php I taught myself.

I just want to retrieve the JSON using the getFeeds command.

I found the cURL manual on php.net, but there isn't anything there that looks like the command line in the Wiki on the Tiny Tiny RSS site.

I also found an example of an HTTP Post using a form on cURL's site, but I can't figure out where the command line would go in relation. It seems like I need more than just the command line, but I'm not sure exactly what.

Sorry to be such a newbie, but I'm trying to come up with a replacement for Google Reader before it's too late. I have an entire page on my website that will go down without it.

Thanks!!!

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

Re: How to use cURL to call the API

Postby fox » 05 Apr 2013, 12:13

Curl has a binary on linux (and you should be able to find one installable with cygwin on windows), which is what the page references. You can also use whatever utility or site capable of sending json over http post data.

redheadkelly
Bear Rating Trainee
Bear Rating Trainee
Posts: 11
Joined: 05 Apr 2013, 11:50

Re: How to use cURL to call the API

Postby redheadkelly » 05 Apr 2013, 14:02

I'm happy to use cURL. It''s already installed on my server. (Linux)

I'm just having trouble with the php that I need to write in order to call the API. The wiki isn't complete enough for a beginner.

Can you just point me to some examples of how to actually construct the php? I found lots of them out there, but the wiki makes it seem like a call should be structured like this:

Code: Select all

$ curl -d '{"sid":"your-session-id","op":"getVersion"}' http://example.dom/tt-rss/api/


But none of the examples make sense this way, so I'm assuming it must be done differently.

Thanks.

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

Re: How to use cURL to call the API

Postby fox » 05 Apr 2013, 14:08

The point of the wiki is to outline interaction with tt-rss API, not to teach you programming PHP.

User avatar
raindog469
Bear Rating Trainee
Bear Rating Trainee
Posts: 17
Joined: 17 Mar 2013, 22:35

Re: How to use cURL to call the API

Postby raindog469 » 05 Apr 2013, 15:45

redheadkelly wrote:I'm happy to use cURL. It''s already installed on my server. (Linux)
Can you just point me to some examples of how to actually construct the php? I found lots of them out there, but the wiki makes it seem like a call should be structured like this:

Code: Select all

$ curl -d '{"sid":"your-session-id","op":"getVersion"}' http://example.dom/tt-rss/api/


That's not PHP, that's JSON. It's a standard Javascript way of defining objects, and most modern web APIs use it to pass data.

If you want to learn how to construct API requests, fire up the new mobile version of tt-rss in Chrome, press F12 to enable the debugger, go to the Network tab, then log in and start clicking around. You'll see requests like

Code: Select all

{"op":"isLoggedIn"}
{"op":"login","user":"nota","password":"realuser"}
{"op":"getCategories","enable_nested":"false"}
{"op":"getConfig"}
{"op":"getFeeds","cat_id":-4,"include_nested":false}
{"op":"getHeadlines","show_excerpt":false,"view_mode":"adaptive","show_content":true,"limit":20,"feed_id":490}
{"op":"updateArticle","article_ids":66108,"mode":0,"field":2}

That's what I got from logging in and 3 clicks. It seems pretty consistent with the wiki and self-explanatory to me and my preferred language is not PHP.

redheadkelly
Bear Rating Trainee
Bear Rating Trainee
Posts: 11
Joined: 05 Apr 2013, 11:50

Re: How to use cURL to call the API

Postby redheadkelly » 05 Apr 2013, 16:46

Yes, I was just coming back here to say that I'm getting now that it needs to be javascript, not php. I don't ever do anything in that, so that's why it wasn't clear to me. I guess now is my time to start learning it. Ha.

Thanks so much for your help.

j0nson
Bear Rating Trainee
Bear Rating Trainee
Posts: 21
Joined: 16 Mar 2013, 04:41

Re: How to use cURL to call the API

Postby j0nson » 05 Apr 2013, 17:17

redheadkelly wrote: I'm getting now that it needs to be javascript, not php.


No, the request method makes no difference to the API.

If you are looking for an example of PHP curl requests to the ttrss API, you should look at the greader-like mobile page. While it uses JavaScript calls for some actions, most of the work is done by PHP curl.

http://tt-rss.org/forum/viewtopic.php?f=10&t=1335


Return to “Knowledge Base”

Who is online

Users browsing this forum: No registered users and 1 guest