Showing posts with label api. Show all posts
Showing posts with label api. Show all posts

Sunday, June 26, 2011

Added LinkedIn API Integration

My Question on Support site for LampCMS project

I am finished with the LinkedINAPI module.
It's done and pushed to github.

It's now possible to add "Login with LinkedIn" button to the list of existing buttons.
Also when posting Question or Answer there is an option to also post to LinkedIn. The link to your Question or Answer will then be sent to LinkedIn and will be visible by people on your network on LinkedIn.

This is similar to "Sharing" on Twitter.

As with other social sites it's also possible to add LinkedIn to your existing account from the Viewing your profile page while logged in to site.

Also if you check the "Post to LInkedIn" checkbox on the "Ask" or "Answer" form and your account is not connected to LinkedIn, the small window will popup starting the "Connect to LinkedIn" process.

The new section [LINKEDIN] is added to the !config.ini.dist (which you rename to !config.ini)
Instructions on how to get your LinkedInAPI key are in that section.

Click here to post your reply


Thursday, June 16, 2011

Lampcms Write API

My Question on Support site for LampCMS project

I said before that OAuth2 (or Oauth1) based API will not be free. This is still true.
But I also decided to still write a write API, based on Basic Auth. Basic Auth is a simple authentication where username and password are sent in request headers. This is the old standard. When Twitter API first came out it was based on Basic Auth, then for some time it was still available even after they released OAuth api, then finally they discontinued it.

Basic Auth in not secure but can still be OK if used with https urls.

Some (maybe even many) APIs out there still support Basic Auth, for example github API has such support.

Anyway, I added the support for Basic Auth and wrote 2 write API controllers: addquestion and addanswer

I am still testing the addanswer but addquestion already works.

This all means that you can start writing apps for Lampcms, for example maybe an Android app or web app.
More write API controllers will be added soon, like retag, edit, addcomment, vote, acceptanswer, delete, flag, close

You should ask questions here if you need more details on how to write apps for Lampcms and how to use API in general.

Click here to post your reply


Friday, June 10, 2011

Lampcms REST API update

My Question on Support site for LampCMS project

Hello!
Just want to share some progress of the LampCMS API work:

Any good API must have a way for developers to quickly register their APP and get a unique API KEY.

I have added this feature. This is how it works: most api calls can be made without the API KEY but the daily rate limit will be low without the key. With the valid API KEY the daily limit is much higher. All these limits are configures from !config.ini

So this is how it works: If you want to add API to your Lampcms powered site you need to tell developers how to register their app. All you do is point them to /viewapps/ url
If use does not have any apps yet, then user is redirected to the form to create new app, otherwise user sees the list of all registered apps and can view and edit any app.

You are welcome to try it here http://support.lampcms.com/viewapps/

Once you have the api key you just add &apikey=somekey to all the API requests

For example: http://support.lampcms.com/api/api.php?a=questions&tags=feature&starttime=1306360958&apikey=yourkey

Replace "youkey" with your new valid key or you will get an error, just as you should in case of invalid api key

Several api controllers are ready. Controllers are identiried by the value of the 'a' param which stands for "action"

So in previous example url the "a" is "Questions"

Other controllers are "users" - get info on any user(s) by passing comma-separated values of "uids" param
You can also just call /api/api.php?a=users with no params to get all users and can user pageID and limit params to paginate results. Results can also be sorted using sort= and dir=
for example sort=i_rep&dir=desc to sort by reputation in descending order

Another controllers:


"tags" to get tags data,

"relatedtags" to get related tags - pass tag=sometag to get related data of "sometag"

"usertags" to get tags user's active tags. Pass userID in uid param

"isfollowing" to check if user identified by uid is following another user (or tag or question) identified by "val"
For example: /api/api.php?a=isfollowing&uid=3&t=q&val=125
Will return is_following = true if user with id 3
is following question with id 125

For example /api/api.php?a=isfollowing&uid=3&t=u&val=23
Will return is_following = true IF user with id 3 IS FOLLOWING
user with id 23 (false if not following)

I will push all the latest stuff to github soon so you can examine the API controllers for yourself.





Click here to post your reply


Sunday, June 5, 2011

Lampcms REST API preview

My Question on Support site for LampCMS project

Hello!

Just want to let you know the status of the API work. Here is what I wrote so far:

Wrote base class for the API, wrote a new type of class called Output. This represents the content that is ready to be sent out to the client and it specific to the output format. Concrete classes representing the output format like Json or XML or Jsonp extend this class.

Wrote the Response class - it represents the body and headers ready to be sent to the client (usually browser but any API client really)

Added a new section to !config.ini called [API]

It has these params:
; Maximum results an API can return per page
MAX_RESULTS = 100
; Dalily access limit for not logged in users
DAILY_LIMIT_ANON = 150
; Daily access limit for logged in users
DAILY_LIMIT_APP = 3000
; Daily limit for authenticated user
DAILY_LIMIT_USER = 10000


Using these settings you can completely restring the access to API to only your partner sites by settings DAILY_LIMIT_ANON = 0
It will prevent any access by anonymous clients


API already supports these basic features: makes use of Http response headers and specific HTTP status codes. For example 404 when content not fount or 406 when the value of request parameter is invalid or 500 in case of error in API

Support for custom headers to indicate client's daily rate limit:
X-RateLimit-Limit
X-RateLimit-Remaining
X-RateLimit-Reset
The X-RateLimit-Reset is the timestamp of the next time limit is reset which is usually the beginning of the next day since rate limit is per day.

API currently supports 2 output formats: JSON and JSONP
support for XML can easily be added by just writing the custom OutputXML class. No changes to other classes will be necessary.

API has support for versioning. This is how most good APIs work - when new version of API is released the old ones still work, so your client programs are not broken. You can just pass the v (version id) in request and start using the new version of API. Current version is 1

Currently I wrote 2 API controllers: questions and question

This is how you use it:
Example URL for api is: domain/api/api.php?v=1&a=questions&start_id=5&limit=1&sort=i_votes&dir=desc&alt=json

Here is the explanation of params:

v = version of API, optional, defaults to 1, so for now you can omit it as 1 is the only version

a = "action" Currently completed controllers for "questions" and "question" actions

limit = number of results to return per API call. Think of it as a per-page number on the website.
sort = sort results by this param. For "questions" allowed values are i_votes to sort by votes,
i_lm_ts to sort by "last modified timestamp",
_id to sort by question id,
i_ans to sort by number of answers

dir = direction of sorting. Allowed values are asc for ascending or desc for descending (default)

start_id = show questions with id greated than this (but not including this) id.

max_id = show questions with id less than but not including this id

starttime = unix timestamp in GMT. Show questions posted after this time

tags = space separated tags. Request must be urlencoded so space char should be replaced with %20
show only questions with these tags

match = when tags value is set you can use this param to set to "all" or "any" to match questions with any of the tags or to return questions that must contain all of the tags

uid = userID. Return only questions posted by this user.

type = Return only questions of this type. Allowed values are: "unans" to return only questions with no answers,
"answrd" to return questions with answers by not with "Accepted" answer, "accptd" to return only questions that have an "Accepted" answer.

Extra params: comments=yes to also include comments (by default comments not included)
body=yes to also include full body of question. By default only the "intro", a short text-only version of the first 150 chars of question is included

You can mix these params. For example you can easily get only unanswered questions that have certain tags and posted after certain time.


Question controller.

This controller returns data for one question specified by the qid param.
Example : domain/api/api.php?a=question&qid=5&sort=i_votes&limit=4

Here the limit applies to number of Answers included in response.
For Question controller you can also sort by "accepted", for example: sort=accepted&limit=1
will return only 1 answer that is an "Accepted" answer.


For both questions and question controllers the returned data includes number of total results and the pageID.
Default pageid = 1, you can pass the pageID in request in order to get questions that did not fit in the per-page limit and you know that are more results. In such cases you use the pagination by passing pageID value


You can review the source files for more info. API classes are in /lib/Lampcms/Api/ folder

More API controllers will be released soon: tags, tag, users, user, answers
As well as web controller to register the client and to get clientID.







Click here to post your reply


Tuesday, May 31, 2011

Beginning work on the Lampcms API

My Question on Support site for LampCMS project

Yes, the Lampcms will have an API. It will be one of the few Open Source Q&A programs that has own API.

Before I beging working on the API, here are some basic outlines of what it will do:

1) Output will be in JSON or XML, but first I'll work on JSON version since it's much simpler. But right from the start the output will be handled by the formatter class. That class will accept raw data (php array or object) and convert it into JSON or XML. So first I'll just write JSON formatter)

2) It will be read/write API. First I'll work on read functions, then on write.

3) Good news and bad news about write API. Good news - it will be OAuth2, which is harder to write for me but easier to use for clients. Bad news - this will be one module which that will not be free. Yes, it will be the first premium module. After all, if you need the write API you are probably building a very interesting project with the purpose of making a profit. So it will not be a big deal to pay for this module. It will not be expensive anyway.

So, here you have it - a free read API with support to get latest questions, unanswered, by tag(s), support for "startwith" and "limit" and "sort by" options

Support to get all answers for a question with "startwith", "limit" and "sort" options and support for include/exclude comments from data

Support for questions for specific user, answers by specific user.

Maybe other options like get following/followers per user, but that will come later.

Any suggestions? Post them here.

Click here to post your reply


Monday, May 9, 2011

Should we use simpler Link and Image tool in Editor?

My Question on Support site for LampCMS project

I know that adding link in Editor brings up a form that is somewhat messed-up, some times more messed up than others. I found that the Editor resize utility, while is kind-of cool and I like it, cases the problem with the link form and also with image form (we don't have image tool right now but I tested it)

So the solution would be to either get rid of resize utility in Editor or use simple prompts to enter url for link and url for image.

The Editor will still be auto-resizable, meaning when you keep typing longer posts and need more height, the Editor will just auto-expand.

You can also see examples of simple Link and Image tools here on YUI demo page: http://developer.yahoo.com/yui/examples/editor/simple_adv_editor.html

I am leaning more towards getting rid of resize and keeping advanced link and image options, but this is still open for discussion.

Click here to post your reply


Sunday, May 8, 2011

Added Blogger API support

My Question on Support site for LampCMS project

We now have an option to post Question or Answer to user's blog on Blogger via bloggerAPI.
Just like our Tumblr module it uses OAuth authentication.

Use can "connect" blogger blog from their profile page or from the "Ask" or "Answer" form when they click the "Post to blogger" check box and their account is not yet connected to Blogger.

More social features means more traffic for your site. Imagine a user with popular blog decides to share a question on a blog. That would mean a lot more new visitors to your Q&A site.

In the future we may also be able to monitor that post on blogger an any comments made on blogger will be imported as comments to that question or answer.

Also comments added to Question or Answer or an answer to a question made on the site may be posted to blogger's post as comments. This of cause is pretty dangerous feature because if someone posts a spam on your site we sure don't want to propagate that spam to someone else's blog.

Click here to post your reply


Saturday, May 7, 2011

Tumblr support added

My question on Support site for LampCMS project

I finished the TumblrAPI module.
User can now send Question or Answer to their Tumblr blog at the time of posting.

It uses OAuth authentication, just like Twitter API.

So source is on github.

I will work on few minor changes next like not including deleted items in views even for administrators
Instead there will be a separate controller to view deleted items and only administrator will be able to use it.

Click here to post your reply