Api - nouvelingenieur/Refresh GitHub Wiki
API
The api files are stored in SITE/api/
They are JSON outputs from the database for the APP.
You can query the API using a GET method. This means that the inputs can be given in the URL.
For example:
http://refresh.nouvelingenieur.fr/api/ideas.php?n=3&c=1
where argument n is set to 7 and argument c is set to 1.
Security
- string EMAIL: sha1 crypted email of the user
- string PASSWORD: sha1 crypted password
These two strings will be necessary for each call to the API to succeed. They are crypted so that a sniffer could not access the clear login information.
Info
Returns basic info about the current configuration of the linked Refresh installation.
File
SITE/api/info.php
Input
None
Output
- string LANG : language of the current Refresh installation
- string NOM_ECOLE : name of the school for the current Refresg installation
- string MAIL_CONTACT : contact email for the current platform
Sample JSON
Ext.util.JSONP.callback({"data":{
"LANG":"fr_FR",
"NOM_ECOLE":"Education",
"MAIL_CONTACT":"[email protected]"
}})
Ideas
Retrieve ideas from the database for display purposes.
File
SITE/api/ideas.php
Input
- string EMAIL: sha1 crypted email of the user
- string PASSWORD: sha1 crypted password
- string q : search query
- integer c : id of the category to search (if id=0, then all categories)
Output
- integer IDEA_ID : id
- integer IDEA_CATEOGRY_ID : id of the idea's category
- string IDEA_TITLE : title (non unique)
- string IDEA_TEXT : text of the idea
- date IDEA_DATE : date of the posting of the idea
- string IDEA_AUTHOR : name of the author if available
- integer IDEA_POSITIVE_VOTES : number of positive votes
- integer IDEA_NEGATIVE_VOTES : number of negative votes
Sample JSON
Ext.util.JSONP.callback({"data":[
{"IDEA_ID":"7",
"IDEA_CATEOGRY_ID":"1",
"IDEA_TITLE":"Design",
"IDEA_TEXT":"Des cours\/projets optionnels de Design\/Web Design",
"IDEA_DATE":"2011-09-06 14:05:46",
"IDEA_AUTHOR":"Eldraelin ",
"IDEA_POSITIVE_VOTES":"5",
"IDEA_NEGATIVE_VOTES":"2"}
{"IDEA_ID":"9",
"IDEA_CATEOGRY_ID":"1",
"IDEA_TITLE":"Annales examens",
"IDEA_TEXT":null,
"IDEA_DATE":"2011-11-01 18:28:25",
"IDEA_AUTHOR":"Eldraelin ",
"IDEA_POSITIVE_VOTES":"5",
"IDEA_NEGATIVE_VOTES":"2"}
]})
Categories
Get a list of all categories available in the platform.
File
SITE/api/categories.php
Input
- string EMAIL: sha1 crypted email of the user
- string PASSWORD: sha1 crypted password
Output
- integer CATEOGRY_ID : id
- string CATEGORY_NAME : name of the category
Sample JSON
Ext.util.JSONP.callback({"data":{"LANG":"fr_FR","NOM_ECOLE":"Education","MAIL_CONTACT":"[email protected]"}})
Post
Post an idea to Refresh.
File
SITE/api/post.php
Input
- string EMAIL: sha1 crypted email of the user
- string PASSWORD: sha1 crypted password
- string IDEA_TITLE : title (non unique)
- string IDEA_TEXT : text of the idea
- integer IDEA_CATEOGRY_ID : id of the idea's category (if 0 then default)
- double IDEA_LAT : latitude (for geolocalization)
- double IDEA_LONG : longitude (for geolocalization)
####Output
- bool IDEA_POSTED : 'True' if idea posted correctly else 'False'
Login
Log the user into Refresh.
File
SITE/api/login.php
Input
- string EMAIL: sha1 crypted email of the user
- string PASSWORD: sha1 crypted password
- string SERVER_URL: url of the server
####Output
- bool SUCCESS: 'True' if succes, else 'False'
- string MESSAGE: 'This User is authorized' if success, 'User doesn't exist', 'User and password do not match' 'Password is required'
Get Comments
Retrieves all the comments associated with an idea.
File
SITE/api/get_comments.php
Input
- string EMAIL: sha1 crypted email of the user
- string PASSWORD: sha1 crypted password
- int IDEA_ID
####Output
- int comment_id: id of the comment
- int is_proprio: 1 if the current user has posted the comment, else 0
- int is_valid: 1 if comment has been accepted, else 0
- int already_mod: 1 if comment has already been moderated, else 0
- date date: date the comment was posted
- string possibly_name: name of the author if available
- string text: text of the comment
- int my_vote: 1 if current user has voted for it, else 0
- int my_provote: 1 if current user has voted +1, else 0
- int pro_vote: total of +1 votes
- int total_vote: total number of votes
Set Comment
Comment on an idea.
File
SITE/api/set_comment.php
Input
- string EMAIL: sha1 crypted email of the user
- string PASSWORD: sha1 crypted password
- int IDEA_ID
- string COMMENT_TEXT
- string POSSIBLY_NAME: non crypted left part of the author's email address
####Output
Vote Idea
Vote for an idea.
File
SITE/api/vote_idea.php
Input
- string EMAIL: sha1 crypted email of the user
- string PASSWORD: sha1 crypted password
- integer IDEA_ID
- integer VOTE_VALUE: 1 agree or 0 disagree
- string POSSIBLY_NAME: non crypted left part of the author's email address
####Output
- integer IDEA_POSITIVE_VOTES : number of positive votes
- integer IDEA_NEGATIVE_VOTES : number of negative votes
Vote Comment
Vote for a comment.
File
SITE/api/vote_comment.php
Input
- string EMAIL: sha1 crypted email of the user
- string PASSWORD: sha1 crypted password
- integer COMMENT_ID
- integer VOTE_VALUE: 1 agree or 0 disagree
- string POSSIBLY_NAME: non crypted left part of the author's email address
####Output
- integer COMMENT_POSITIVE_VOTES : number of positive votes
- integer COMMENT_NEGATIVE_VOTES : number of negative votes