User comments API not working

Avatar
  • updated
  • Fixed

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. 

Pinned replies
Avatar
Sergey Stukov co-founder
  • Answer
  • Fixed

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


Which type of statistics you want to get?

Avatar
Sergey Stukov co-founder
Quote from Richard Jong
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.

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.

Avatar
Richard Jong
Quote from Sergey Stukov

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);
}