Torin/Darren WhoEver (wolfieboy) wrote in lj_dev,
Torin/Darren WhoEver
wolfieboy
lj_dev

getinterests mode

So, why isn't there a mode to get the interests for a user.
I figure that it should be that difficult to put the following into cgi-bin/ljprotocol.pl:
# Note - this is untested code - but the code is trivial
#
sub getinterests
{
my ($dbs, $req, $err, $flags) = @_;
return undef unless authenticate($dbs, $req, $err, $flags);

my $res = [];
my $dbr = $dbs->{'reader'};

my $sth = $dbr->prepare("SELECT i.interest, i.intcount, i.intid " .
"FROM interests i, userinterests ui " .
"WHERE i.intid=ui.intid AND ui.userid=$u->{'userid'}"
);
$sth->execute;
my %interests = ();
while ($_ = $sth->fetchrow_hashref) {
push @$res, { interest => $_->{'interest'},
};
}
$sth->finish;
return $res;
}

As I said, this code is untested but would be trivial to check. If this is something that would be desired, I can make sure this works and update protocol.dat once someone tells me how.
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 8 comments