0
Fixed

User comments API not working

Richard Jong 7 years ago in API • updated by Sergey Stukov (co-founder) 7 years ago 11

I try to retreive all the comments of a user through the following call:


http://userecho.com/api/users/[user_id]/comments.json?key=[key]


However it always returns a empty array, even for users of which I'm sure they have placed lots of comments.


Furthermore: is it possible to retreive the statistics through the API? I want to back-up the data and analyse the use of the forum. 

Answer

Answer
Fixed

Started investigation of your api issue will place info here soon.


Which type of statistics you want to get?

Thanks for your swift follow-up.

The statistics that are already in the forum are very useful (and I can create my own statistics from the feedback and comments list, only if I can retreive the comments). 


The page-views and visits (upper statistics graph) are currently not accessible through the API and would be a great bonus. This way I can construct the total visitor statistics from the beginning.

We founded why your API calls not receive data. Because your community is private.

We prepare fast solution to enable API access for you.


Also use https:// prefix for KEY security.

Tell us you plan to call API via browser or via server script? 

Answer
Fixed

Started investigation of your api issue will place info here soon.


Which type of statistics you want to get?

Please check API to get comments should work now. Call with https:// prefix.

Hello Sergey, today I started working on the API again.

Retreiving user comments through a script on my local computer doesn't work, if I upload the script to a server it does work. In my browser it also works, however in both ways the list of comments is limited to 50.

The API call for comments on a topic (feedback comments) returns an empty result, both in script and browser.

Is there already some progress in the statistics API?

Using HTTPS in my browser gives a security warning, Chrome recognises the certificate, however it is not complete/outdated.

We support pagination in all requests. By default all queries limited to 50 records.
For pagination we use two params.
page - select page
limit - limit records on page


Will check function that return feedback comments now.

API call for feedback's comments updated and should work now
Awesome, thanks for the quick fix!

About statistics we added experimental call that allow to get visitors and pageviews statistics.


Try
http://userecho.com/api/stat/2011/visitors.json?key=

It will return raw google analytics data for selected year for your community.

Thank you very much, now I've got all statistics in one handy overview!

Tip1: include pagination and limit in the API discription. Tip2: special characters like ë won't pass PHP's json_decode() function (without throwing an error which was pretty frustrating), use utf8_encode() first.
Here is the code I created, maybe has some use for others. 


$file = file('your_analytics_data_here.txt'); 

foreach($file as $line){

    $datePos = strpos($lines, ';ga:date=');
    //find next value enclosure
    $datePosClose = strpos($line, '&', $datePos);
    $dateTextPos = strpos($line, 'value=\"', $datePos+10);
    //find next value enclosure
    $dateTextPosClose = strpos($line, '\"', $dateTextPos+8);
    $visitorsPos = strpos($line, 'value=\"', $dateTextPos+10);
    //find next value enclosure
    $visitorsPosClose = strpos($line, '\"', $visitorsPos+8);
    $pageviewsPos = strpos($line, 'value=\"', $visitorsPos+10);
    //find next value enclosure
    $pageviewsPosClose = strpos($line, '\"', $pageviewsPos+8);
    $date = substr($line, $datePos+9, $datePosClose-$datePos-9);
    $dateText = substr($line, $dateTextPos+8, $dateTextPosClose-$dateTextPos-8);
    $visitors = substr($line, $visitorsPos+8, $visitorsPosClose-$visitorsPos-8);
    $pageviews = substr($line, $pageviewsPos+8, $pageviewsPosClose-$pageviewsPos-8);
}
and by the way, nice mouse-tracking gimmick on your about-page ;)