The Qhub API is a simple protocol set that allows developers to write their own interfaces for a hub's content, including its questions, answers and members.
The Qhub API is a standard developer-oriented interface to the main features available to a Qhub. It allows the construction of customised third-party applications that will encourage the growth of specific Qhubs and the Qhub system as a whole.
The API is available to any user registered to a Qhub. Each API request must be validated according to an active user within a specified Qhub.
Only approved and preapproved contributions will be returned, and relevant members must exist and be active.
There are API usage limits, according to requests per hour (by IP). Frequencies of requests are constantly monitored. Extreme usages will be automatically banned.
All requests require validation.
HTTP is used as the basic protocol. GET methods required, unless the method specifically performs a data insertion, deletion or update - in which case, a POST method is used.
Response data is either XML or JSON.
Returns success/failure.
URL: http://api.qhub.com/HUB_URL/verify.FORMAT
HUB_URL: domain name of the hub e.g. example.qhub.com
FORMAT: xml, json
HTTP Method: POST
Requires Authentication: true
API rate limited: true
Parameters: required
Filters: none
Example:
require_once 'class.qhub.php';
$qhub = new qhub('example.qhub.com','your_user_id','your_password','your_api_key');
$url = "/verify.xml";
$postfields = array(
'user_id'=>'your_user_id'
);
$result = $qhub->request($url, $postfields);
echo '<pre>';
echo htmlspecialchars($result);
echo '</pre>';
Response: success
<?xml version="1.0"?>
<response status="ok">
true
</response>
Response: failure
<?xml version="1.0"?>
<response status="fail">
ERROR_MESSAGE
</response>
Returns success/failure.
URL: http://api.qhub.com/HUB_URL/ask.FORMAT
HUB_URL: domain name of the hub e.g. example.qhub.com
FORMAT: xml, json
HTTP Method: POST
Requires Authentication: true
API rate limited: true
Parameters: required
Filters: none
Example:
require_once 'class.qhub.php';
$qhub = new qhub('example.qhub.com','your_user_id','your_password','your_api_key');
$url = "/ask.xml";
$postfields = array(
'question'=>"Where Can I Get Help With Qhub?",
'tags'=>'qhub,help',
'user_id'=>'your_user_id'
);
$result = $qhub->request($url, $postfields);
echo '<pre>';
echo htmlspecialchars($result);
echo '</pre>';
Response: success
<?xml version="1.0"?>
<response status="ok">
Your question has been successfully saved. <a href="http://QUESTION_LINK">QUESTION_LINK</a>
</response>
Response: failure
<?xml version="1.0"?>
<response status="fail">
ERROR_MESSAGE
</response>
Returns success/failure.
URL: http://api.qhub.com/HUB_URL/answer.FORMAT
HUB_URL: domain name of the hub e.g. example.qhub.com
FORMAT: xml, json
HTTP Method: POST
Requires Authentication: true
API rate limited: true
Parameters: required
Filters: none
Example:
require_once 'class.qhub.php';
$qhub = new qhub('example.qhub.com','your_user_id','your_password','your_api_key');
$url = "/answer.xml";
$postfields = array(
'answer'=>"Together we can help each other create better, more beautiful websites.",
'question_id'=>123,
'user_id'=>'your_user_id'
);
$result = $qhub->request($url, $postfields);
echo '<pre>';
echo htmlspecialchars($result);
echo '</pre>';
Response: success
<?xml version="1.0"?>
<response status="ok">
Your answer has been successfully saved. <a href="http://QUESTION_LINK">QUESTION_LINK</a>
</response>
Response: failure
<?xml version="1.0"?>
<response status="fail">
ERROR_MESSAGE
</response>
Returns a list of associative array of questions (question, question ID, user ID, user Name, date created, tags, num answers) in the specified hub.
URL: http://api.qhub.com/HUB_URL/questions.FORMAT[?FILTER[&FILTER]]
HUB_URL: domain name of the hub e.g. example.qhub.com
FORMAT: xml, json
HTTP Method: GET
Requires Authentication: true
API rate limited: true
Filters: optional
Note that if the order filter is not specified, the api will return the newest question first.
Note also that if the order filter is popular, then the api will ignore all filters but the limit filter.
Example:
http://api.qhub.com/example.qhub.com/questions.xml?type=answered&user_ids[]=1&user_ids[]=2&tags[]=ab&tags[]=cd
&datefrom=2010-01-01&dateto=2010-01-31&order=popular&limit=4
Response:
<?xml version="1.0"?>
<response status="ok">
<item>
<question>What is A?</question>
<question_id>1</question_id>
<user_id>1</user_id>
<user_name>ABC</user_name>
<tags>ab,cd</tags>
<date_created>2010-02-11 15:35:09</date_created>
<num_answers>4</num_answers>
</item>
<item>
<question>What is B?</question>
<question_id>2</question_id>
<user_id>2</user_id>
<user_name>BCD</user_name>
<tags>ab,ef</tags>
<date_created>2010-02-12 15:35:09</date_created>
<num_answers>0</num_answers>
</item>
<item>
<question>What is C?</question>
<question_id>3</question_id>
<user_id>3</user_id>
<user_name>CDE</user_name>
<tags>ab,cd</tags>
<date_created>2010-02-13 15:35:09</date_created>
<num_answers>1</num_answers>
</item>
<item>
<question>What is D?</question>
<question_id>4</question_id>
<user_id>4</user_id>
<user_name>DEF</user_name>
<tags>cd,ef</tags>
<date_created>2010-02-15 15:35:09</date_created>
<num_answers>2</num_answers>
</item>
</response>
Returns a list of associative array of a question (question, question ID, user ID, user Name, date created, tags, num answers) in the specified hub.
URL: http://api.qhub.com/HUB_URL/question/QUESTIONID.FORMAT
HUB_URL: domain name of the hub e.g. example.qhub.com
FORMAT: xml, json
HTTP Method: GET
Requires Authentication: true
API rate limited: true
Parameters: QUESTION_ID (Required)
Filters: none
Example:
http://api.qhub.com/example.qhub.com/question/123.xml
Response:
<?xml version="1.0"?>
<response status="ok">
<item>
<question>What is ABC?</question>
<question_id>123</question_id>
<user_id>1</user_id>
<user_name>ABC</user_name>
<tags>ab,cd</tags>
<date_created>2010-02-11 15:35:09</date_created>
<num_answers>2</num_answers>
</item>
</response>
Returns a list of associative array of answers (answer, answer ID, question ID, use IDs, userName, date created) in the specified hub.
URL: http://api.qhub.com/HUB_URL/answers.FORMAT[?FILTER[&FILTER]]
HUB_URL: domain name of the hub e.g. example.qhub.com
FORMAT: xml, json
HTTP Method: GET
Requires Authentication: true
API rate limited: true
Filters: optional
Example:
http://api.qhub.com/example.qhub.com/answers.xml?user_ids[]=1&user_ids[]=2&tags[]=ab&tags[]=cd&datefrom=2010-01-01&dateto=2010-01-31&limit=4
Response:
<?xml version="1.0"?>
<response status="ok">
<item>
<answer>answer 3</answer>
<answer_id>3</answer_id>
<question_id>1341</question_id>
<user_id>1</user_id>
<user_name>A Smith</user_name>
<date_created>2010-02-11 15:35:09</date_created>
</item>
<item>
<answer>answer 4</answer>
<answer_id>4</answer_id>
<question_id>1394</question_id>
<user_id>1</user_id>
<user_name>A Smith</user_name>
<date_created>2010-02-11 14:39:49</date_created>
</item>
<item>
<answer>answer 5</answer>
<answer_id>5</answer_id>
<question_id>1341</question_id>
<user_id>2</user_id>
<user_name>B Smith</user_name>
<date_created>2010-02-09 14:36:16</date_created>
</item>
<item>
<answer>answer 6</answer>
<answer_id>6</answer_id>
<question_id>461</question_id>
<user_id>2</user_id>
<user_name>B Smith</user_name>
<date_created>2010-02-03 22:10:22</date_created>
</item>
</response>
Returns a list of associative array of an answer (answer, answer ID, question ID, use ID, userName, date created) in the specified hub.
URL: http://api.qhub.com/HUB_URL/answer/ANSWERID.FORMAT
HUB_URL: domain name of the hub e.g. example.qhub.com
FORMAT: xml, json
HTTP Method: GET
Requires Authentication: true
API rate limited: true
Parameters: ANSWERID
Filters: none
Example:
http://api.qhub.com/example.qhub.com/answer/1.xml
Response:
<?xml version="1.0"?>
<response status="ok">
<item>
<answer>answer 7</answer>
<answer_id>1</answer_id>
<question_id>1341</question_id>
<user_id>1</user_id>
<user_name>A Smith</user_name>
<date_created>2010-02-11 15:35:09</date_created>
</item>
</response>
Returns list of associative array of members (user id, user name, type, question count, answer count, date joined) in the specified hub.
URL: http://api.qhub.com/HUB_URL/members.FORMAT[?FILTER[&FILTER]]
HUB_URL: domain name of the hub e.g. example.qhub.com
FORMAT: xml, json
HTTP Method: GET
Requires Authentication: true
API rate limited: true
Filters: optional
Example:
http://api.qhub.com/example.qhub.com/members.xml?datefrom=2010-01-01&dateto=2010-01-31&limit=2
Response:
<?xml version="1.0"?>
<response status="ok">
<item>
<user_id>987654321</user_id>
<user_name>A</user_name>
<type>member</type>
<date_joined>2010-01-31 17:46:38</date_joined>
<num_questions>0</num_questions>
<num_answers>1</num_answers>
</item>
<item>
<user_id>987654322</user_id>
<user_name>B</user_name>
<type>member</type>
<date_joined>2010-01-31 14:00:22</date_joined>
<num_questions>0</num_questions>
<num_answers>1</num_answers>
</item>
</response>
Returns list of the contributions of a members in the specified hub.
URL: http://api.qhub.com/HUB_URL/member/USER_ID.FORMAT[?FILTER[&FILTER]]
FORMAT: xml, json
HTTP Method: GET
Requires Authentication: true
API rate limited: true
Filters: optional
Examples:
1. http://api.qhub.com/example.qhub.com/member/1.xml?contrib=question&datefrom=2010-01-01&dateto=2010-01-31&limit=2
2. http://api.qhub.com/example.qhub.com/member/1.xml?contrib=answer&datefrom=2010-01-01&dateto=2010-01-31&limit=2
3. http://api.qhub.com/example.qhub.com/member/1.xml?contrib=all&datefrom=2010-01-01&dateto=2010-01-31&limit=4
(same as http://api.qhub.com/example.qhub.com/member/1.xml?datefrom=2010-01-01&dateto=2010-01-31&limit=4)
Response:
example 1.
<?xml version="1.0"?>
<response status="ok">
<item>
<answer>answer 1</answer>
<answer_id>1</answer_id>
<question_id>2007</question_id>
<user_id>1</user_id>
<user_name>A Smith</user_name>
<date_created>2010-01-27 11:36:48</date_created>
</item>
<item>
<answer>answer 2</answer>
<answer_id>2</answer_id>
<question_id>1906</question_id>
<user_id>1</user_id>
<user_name>A Smith</user_name>
<date_created>2010-01-07 18:30:37</date_created>
</item>
</response>
example 2.
<?xml version="1.0"?>
<response status="ok">
<item>
<question>question 1</question>
<question_id>2007</question_id>
<user_id>1</user_id>
<user_name>A Smith</user_name>
<date_created>2010-01-27 11:36:48</date_created>
<tags>blog</tags>
<num_answers>1</num_answers>
</item>
<item>
<question>question 2</question>
<question_id>2005</question_id>
<user_id>1</user_id>
<user_name>A Smith</user_name>
<date_created>2010-01-27 09:23:37</date_created>
<tags>Computer networks,networks</tags>
<num_answers>0</num_answers>
</item>
</response>
example 3. Server returns 2 answers and 2 questions
Returns list of associative array of tags (tag name, question count) in the specified hub.
URL: http://api.qhub.com/HUB_URL/tags.FORMAT
HUB_URL: domain name of the hub e.g. example.qhub.com
FORMAT: xml, json
HTTP Method: GET
Requires Authentication: true
API rate limited: true
Filters: none
Example:
http://api.qhub.com/example.qhub.com/tags.xml
Response:
<?xml version="1.0"?>
<response status="ok">
<item>
<tag>ab</tag>
<num_questions>2</num_questions>
</item>
<item>
<tag>bc</tag>
<num_questions>3</num_questions>
</item>
<item>
<tag>cd</tag>
<num_questions>1</num_questions>
</item>
...
<item>
<tag>yz</tag>
<num_questions>0</num_questions>
</item>
</response>
Returns list of the questions in a tag in the specified hub.
URL: http://api.qhub.com/HUB_URL/tags/TAG_NAME.FORMAT[?FILTER[&FILTER]]
FORMAT: xml, json
HTTP Method: GET
Requires Authentication: true
API rate limited: true
Filters: optional
Examples:
http://api.qhub.com/example.qhub.com/tags/abc.xml?type=unanswered&user_ids[]=1&user_ids[]=2&limit=2
Response:
<?xml version="1.0"?>
<response status="ok">
<item>
<question>What is A?</question>
<question_id>1</question_id>
<user_id>1</user_id>
<user_name>ABC</user_name>
<tags>abc,cd</tags>
<date_created>2010-02-11 15:35:09</date_created>
<num_answers>4</num_answers>
</item>
<item>
<question>What is B?</question>
<question_id>2</question_id>
<user_id>2</user_id>
<user_name>BCD</user_name>
<tags>abc,ef</tags>
<date_created>2010-02-12 15:35:09</date_created>
<num_answers>0</num_answers>
</item>
</response>
Returns list of the stats of the specified hub.
URL: http://api.qhub.com/HUB_URL/stats.FORMAT[?FILTER[&FILTER]]
FORMAT: xml, json
HTTP Method: GET
Requires Authentication: true
API rate limited: true
Filters: none
Examples:
http://api.qhub.com/example.qhub.com/stats.xml
Response:
<?xml version="1.0"?>
<response status="ok">
<item>
<date_created>2010-01-01 00:00:01</date_created>
<num_members>1500</num_members>
<num_active_members>1455</num_active_members>
<num_questions>12345</num_questions>
<num_answers>13454</num_answers>
</item>
</response>
|
OnClick Solutions Ltd is a small company focused on providing affordable, simple web applications to help your business evolve.
Visit our company website.
More websites: Simple Billing Software, Simple Project Management , Websites for sale in Israel |