SQL/User API?

Need help? Post your questions here.

Moderator: moderators

SQL/User API?

Postby nizchetus » Tue Jul 03, 2012 9:53 pm

Maybe this was answered somewhere, but searching "SQL" brings back no results.

It seems like this is managed with SQL, but where are the databases? I have mySQL installed on my server box, but I'm seeing no entries at all. Is it stored in it's own little server? Is it stored off-site?

I'm running 4.7.beta2 (build 3011) on a headless Ubuntu 12.04 box, and I'd like to use the user login for a website where I'll be making a blog and forum, instead of having my users create two accounts, I'd like to grab the user data from the Subsonic SQL database, or if there isn't one... then some sort of API to allow PHP login from an off-site webserver?

Anyone know if this is possible?
nizchetus
 
Posts: 9
Joined: Thu Dec 01, 2011 12:45 am

Re: SQL/User API?

Postby BKKKPewsey » Tue Jul 03, 2012 10:20 pm

Subsonic uses HSQL

:mrgreen:
Everyone is entitled to be stupid, Image but some abuse the privilege!

Due to the confusion from too many genres of music, we have decided to put both country music and rap music into the genre of Crap music.
User avatar
BKKKPewsey
 
Posts: 2080
Joined: Mon May 23, 2011 12:16 pm
Location: United Kingdom

Re: SQL/User API?

Postby hakko » Wed Jul 04, 2012 5:57 am

You can access the database through http://yourserver/db.view

select * from user
MusicCabinet developer
hakko
 
Posts: 1416
Joined: Tue Apr 17, 2012 7:05 pm
Location: Sweden

Re: SQL/User API?

Postby nizchetus » Wed Jul 04, 2012 1:25 pm

Awesome. Making progress. I've never worked with HSQL; is there a way I can access it through PHP?

Normally, with mySQL, I do a
Code: Select all
mysql_connect('host','user','pass');
mysql_select_db('dbname');

But I assume that only works with mySQL.

And, if there is a way to do that, what port would I use to connect to the HSQL? I assume that I can't use the web-front port.

E: Or, better yet, some way to keep the mySQL DB synced with Subsonic's HSQL DB, and then just pull all data from MySQL.
Last edited by nizchetus on Wed Jul 04, 2012 1:43 pm, edited 1 time in total.
nizchetus
 
Posts: 9
Joined: Thu Dec 01, 2011 12:45 am

Re: SQL/User API?

Postby hakko » Wed Jul 04, 2012 1:43 pm

It seems like people have tried (even though PHP+HSQL feels awkward): http://stackoverflow.com/questions/2204 ... p-question

Why don't you use the Subsonic XML/JSON API instead? It exposes methods to get/create/delete users. http://www.subsonic.org/pages/api.jsp
MusicCabinet developer
hakko
 
Posts: 1416
Joined: Tue Apr 17, 2012 7:05 pm
Location: Sweden

Re: SQL/User API?

Postby nizchetus » Wed Jul 04, 2012 1:44 pm

hakko wrote:It seems like people have tried (even though PHP+HSQL feels awkward): http://stackoverflow.com/questions/2204 ... p-question

Why don't you use the Subsonic XML/JSON API instead? It exposes methods to get/create/delete users. http://www.subsonic.org/pages/api.jsp

I'll give it a shot, I'm just sort of new to web developing, so I really only know HTML/CSS and PHP with any reasonable quality. Was trying to stick with what I know. Thanks.
nizchetus
 
Posts: 9
Joined: Thu Dec 01, 2011 12:45 am

Re: SQL/User API?

Postby hakko » Wed Jul 04, 2012 1:56 pm

I think that connecting to a REST web service from PHP will give you no headaches compared to the HSQL idea. You'll find tons of examples on how to do it. Good luck!
MusicCabinet developer
hakko
 
Posts: 1416
Joined: Tue Apr 17, 2012 7:05 pm
Location: Sweden

Re: SQL/User API?

Postby nizchetus » Wed Jul 04, 2012 4:41 pm

Yeah, I'm stumped. I'm getting nothing. curl_exec is returning no content.

Code: Select all
$url = "http://{$subserver}/rest/getUser.view?u={$username}&p={$password}&username={$username}&v=1.8.0&c={$appID}";

$c = curl_init($url);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
curl_setopt($c, CURLOPT_HEADER, 0);
$result = curl_exec($c);
curl_close($c);

echo $result;


The url itself looks fine. In the web browser, it returns:
Code: Select all
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.8.0">
<user username="xxxxxx" email="xxxxxx@xxxxxx.com" scrobblingEnabled="false" adminRole="true" settingsRole="true" downloadRole="true" uploadRole="true" playlistRole="true" coverArtRole="true" commentRole="true" podcastRole="true" streamRole="true" jukeboxRole="true" shareRole="true"/>
</subsonic-response>


I admit I've never used XML, but according to everything I've read... this should work. And it does work, with other random XML files I found on the web.

E: it might have something to do with the face that it's not an ".xml" file. or any sorta extension. Not sure how to make it work though, still.
nizchetus
 
Posts: 9
Joined: Thu Dec 01, 2011 12:45 am

Re: SQL/User API?

Postby hakko » Wed Jul 04, 2012 5:09 pm

You might get better help at a PHP forum if nobody pops up here...
MusicCabinet developer
hakko
 
Posts: 1416
Joined: Tue Apr 17, 2012 7:05 pm
Location: Sweden

Re: SQL/User API?

Postby nizchetus » Wed Jul 04, 2012 6:10 pm

hakko wrote:You might get better help at a PHP forum if nobody pops up here...

I asked over at stackoverflow... they've got a good base of programmers/designers there. Hopefully I can get an answer soon. It'd be an awesome functionality to have. Maybe I can just convert everything over to OpenID, if I figure out how to edit the webfront login.

Thanks for your help.
nizchetus
 
Posts: 9
Joined: Thu Dec 01, 2011 12:45 am

Re: SQL/User API?

Postby nizchetus » Wed Jul 04, 2012 10:33 pm

Update: Found out that PHP doesn't like grabbing XML from port 4040. Had to change my port, but it works now.
nizchetus
 
Posts: 9
Joined: Thu Dec 01, 2011 12:45 am

Re: SQL/User API?

Postby hakko » Thu Jul 05, 2012 7:16 am

Nice. Thanks for sharing the solution!
MusicCabinet developer
hakko
 
Posts: 1416
Joined: Tue Apr 17, 2012 7:05 pm
Location: Sweden


Return to Help

Who is online

Users browsing this forum: No registered users and 27 guests