Hi Guys
i was trying to use these 2 REST API getFaqs() and getFaq(), it seems like both returning same JSON object.
as documentation says REST API getFaqs() should return this JSON Array/object, something like below
[
{
"record_id":"1",
"record_lang":"en",
"category_id":"1",
"record_title":"Is there life after death?",
"record_preview":"Maybe!",
"record_link":"\/phpmyfaq\/phpmyfaq\/index.php?action=artikel&cat=1&id=1&artlang=en",
"record_date":"20091010175452",
"visits":"3"
},
{"record_id":"2",
"record_lang":"en",
"category_id":"1",
"record_title":"How can I survive without phpMyFAQ?",
"record_preview":"It\'s easy!",
"record_link":"\/phpmyfaq\/phpmyfaq\/index.php?action=artikel&cat=1&id=2&artlang=en",
"record_date":"20091014181500",
"visits":"10"
}
]
but i think its returning this JSON object below, which is same for REST API getFaq()
{
"id":"1",
"lang":"en",
"solution_id":"1000",
"revision_id":"0",
"active":"yes",
"sticky":"0",
"keywords":"",
"title":"Is there life after death?",
"content":"Maybe!",
"author":"Thorsten Rinne",
"email":"thorsten@phpmyfaq.de",
"comment":"y",
"date":"2009-10-10 17:54",
"dateStart":"00000000000000",
"dateEnd":"99991231235959",
"linkState":"",
"linkCheckDate":"0"
}
not sure how should i handle this.
need some help!
Regards
Vik
Possbile Bug in REST API
Moderator: Thorsten
Re: Possbile Bug in REST API
Hi,
the code is different:
But I'll check this issue. How do you call the REST API?
bye
Thorsten
the code is different:
Code: Select all
case 'getFaqs':
$faq = new PMF_Faq($current_user, $current_groups);
$result = $faq->getAllRecordPerCategory($categoryId);
break;
case 'getFaq':
$faq = new PMF_Faq($current_user, $current_groups);
$faq->getRecord($recordId);
$result = $faq->faqRecord;
break;
bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
amazon.de Wishlist
Re: Possbile Bug in REST API
Hi Thorsten
i am using javascript/Jquery/JSON to call the REST API's and i using these json/ajax calls in cross domain, different ports model so i have to use the JSON callbacks (only workaround (ASAIK) to make cross domain ajax calls), but since phpMYFAQ currently does not support JSON call backs so i have to modify the api.php and added a call back function to it, as you can see in the code below i am using google onload call back, i also added a parameter to the REST API (mode) so REST API's can support calls with or without call back. and this change might have caused the issue that i am seeing i will debug more.
here is my code
and here is change in api.php mostly at last line
but i think you are right when i used my browser to make the call it phpMYFAQ's getFaq and getFaqs was returning correct JSON Objects.
one more thing though, currently i can get all the faq's of a category or an individual faq based on record id, is there a way that i can get like " Recenty added Faq " result set. maybe like 20 recently added faq, which can belong to any category?
thanks for your help!
Vikas
i am using javascript/Jquery/JSON to call the REST API's and i using these json/ajax calls in cross domain, different ports model so i have to use the JSON callbacks (only workaround (ASAIK) to make cross domain ajax calls), but since phpMYFAQ currently does not support JSON call backs so i have to modify the api.php and added a call back function to it, as you can see in the code below i am using google onload call back, i also added a parameter to the REST API (mode) so REST API's can support calls with or without call back. and this change might have caused the issue that i am seeing i will debug more.
here is my code
Code: Select all
<title><tiles:getAsString name="title"/></title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="styles/style-new.css" type="text/css" />
<link rel="stylesheet" href="styles/jquery-ui-1.8.2.custom.css" type="text/css" media="all" />
<link rel="stylesheet" href="styles/impromptu.css" type="text/css" media="all" />
<script type="text/javascript" src="js/validation.js"></script>
<script type="text/javascript" src="js/json.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript" src="js/jquery/jquery-1.4.2.min.js" ></script>
<script type="text/javascript" src="js/jquery/jquery-ui-1.8.2.custom.min.js""></script>
<script type="text/javascript" src="js/jquery/jquery-impromptu.js"></script>
<script src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("jquery", "1");
var catUrl = 'http://localhost/phpfaq/api.php?action=getCategories&mode=1';
google.setOnLoadCallback(function() {
$.getJSON(catUrl+'&jsoncallback=?', function(categoriesList){
//alert(categoriesList[0].id + "" +categoriesList[0].name+ "" +categoriesList[0].description);
});
});
var faqUrl = 'http://localhost/phpfaq/api.php?action=getFaqs&lang=en&categoryId=1&mode=1';
google.setOnLoadCallback(function() {
$.getJSON(faqUrl+'&jsoncallback=?', function(recentFaqList){
//alert(recentFaqList[0].record_id + "" +recentFaqList[0].record_title+ "" +recentFaqList[0].record_preview);
//alert(recentFaqList[0].record_link);
});
});
Code: Select all
// print result as JSON
if ( 1 == $mode )
print $_GET['jsoncallback'] . '(' .json_encode($result). ');';
else
print json_encode($result);
one more thing though, currently i can get all the faq's of a category or an individual faq based on record id, is there a way that i can get like " Recenty added Faq " result set. maybe like 20 recently added faq, which can belong to any category?
thanks for your help!
Vikas
Re: Possbile Bug in REST API
Hi,
bye
Thorsten
we have to write a new API function for that, shouldn't be too complicated.vishuvs wrote:one more thing though, currently i can get all the faq's of a category or an individual faq based on record id, is there a way that i can get like " Recenty added Faq " result set. maybe like 20 recently added faq, which can belong to any category?
bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
amazon.de Wishlist