User info PHP API (Now lets make some cool web apps)

jonmullen

Platinum Member
Jun 17, 2002
2,517
0
0
In response to this thread, I decided there are alot of cool community web apps that we could be built. Some of the ones that intrigued me, was the LAN Party management software, and the birthday list. But I figured the hardest part about any of these would be to make sure whatever users try to register are also real users on these forums. So to help with that problem I wrote a PHP API that can access the user profile data on Anandtech and puts it into an easily managable format. You can see a working proof of concept for the API here, and if you wish to see the souce code for the class object is it avaliable here.

I plan to write documentation soon, as well as add some more features as the requests come in. One feature that is in the works is a user search. I am open to suggestions and comments, so feel free to shot back with ideas.
 

jonmullen

Platinum Member
Jun 17, 2002
2,517
0
0
Originally posted by: ndee
ok, that's due to the jrun error from the forums I guess.

yah...now is a bad time to look at it since I have not programmed it to retry if it gets a JRun. I'll add that this weekend.
 

rh71

No Lifer
Aug 28, 2001
52,844
1,049
126
I noticed there's a birthday field in our ATOT profiles, but it's missing with your data extract.

Come to think of it... maybe we can incorporate that into the birthday calendar directly ?
 

jonmullen

Platinum Member
Jun 17, 2002
2,517
0
0
yah, I am still adding fields, I know its not all inclusive, I just wanted to get a proof of concept working and see if there was much intrest in me cont. development.
 

cyberphant0m

Member
Oct 21, 2003
99
0
0
yeah, you could, but it would be better to store it in the object, because then you would be able to use the birthday field in other apps, rather than just in the birthday calendar (such as a Upcoming Birthdays script, or a script that would calculate ages based on birthdays...)
 

jonmullen

Platinum Member
Jun 17, 2002
2,517
0
0
Originally posted by: rh71
I noticed there's a birthday field in our ATOT profiles, but it's missing with your data extract.

Come to think of it... maybe we can incorporate that into the birthday calendar directly ?

Actually I just went back in and played with it, when you set your birthday does it show up when you view your profile. Cuz unless it is public data I can't get to it.
 

jonmullen

Platinum Member
Jun 17, 2002
2,517
0
0
Originally posted by: cyberphant0m
yeah, you could, but it would be better to store it in the object, because then you would be able to use the birthday field in other apps, rather than just in the birthday calendar (such as a Upcoming Birthdays script, or a script that would calculate ages based on birthdays...)

What are you talking about, it is an object if you look at the code all the fields are saved as properties, its just the getUser() method returns an array with all the info just for those programmers who like looping through arrays. In fact the array at present is both index and associative. But that is one of the features I will change later and let you choos which kind or both you want it to return.

If thats not what you were taking about then please elaborate.
 

cyberphant0m

Member
Oct 21, 2003
99
0
0
it doesn't show up...

maybe we can beg the admins to add that to the public data, so that we can play around with it...

if the API develops into something solid, I would be willing to work on an app or two...
 

jonmullen

Platinum Member
Jun 17, 2002
2,517
0
0
Originally posted by: cyberphant0m
it doesn't show up...

maybe we can beg the admins to add that to the public data, so that we can play around with it...

if the API develops into something solid, I would be willing to work on an app or two...

I definatly have the intrest to make it solid, I just want to hear from ppl like you to make sure there is a desire for it before I spend the time polishing it.
 

cyberphant0m

Member
Oct 21, 2003
99
0
0
I would definately be interested in developing a few apps for the AT forums, but only if the MODs decide to somewhat add support, or at least be willing to let us into some more of the user data (obviously not the passwords, but things like birthdays, and the buddy lists... )
 

RossMAN

Grand Nagus
Feb 24, 2000
78,929
390
136
Originally posted by: jonmullen
Originally posted by: cyberphant0m
it doesn't show up...

maybe we can beg the admins to add that to the public data, so that we can play around with it...

if the API develops into something solid, I would be willing to work on an app or two...

I definatly have the intrest to make it solid, I just want to hear from ppl like you to make sure there is a desire for it before I spend the time polishing it.

I would love an ATOT Birthday list. Hopefully the Forum Admins will enable that field of our profile so it's viewable.

If you need hosting for the ATOT Birthday list I can offer a subdomain on Neffing.com
 

DannyBoy

Diamond Member
Nov 27, 2002
8,820
2
81
www.danj.me
Originally posted by: RossMAN
Originally posted by: jonmullen
Originally posted by: cyberphant0m
it doesn't show up...

maybe we can beg the admins to add that to the public data, so that we can play around with it...

if the API develops into something solid, I would be willing to work on an app or two...

I definatly have the intrest to make it solid, I just want to hear from ppl like you to make sure there is a desire for it before I spend the time polishing it.

I would love an ATOT Birthday list. Hopefully the Forum Admins will enable that field of our profile so it's viewable.

If you need hosting for the ATOT Birthday list I can offer a subdomain on Neffing.com

I could write a script for one today and take a break from the discussion board i'm writing, infact it wouldn't be that hard as i've already written the birthday part of the discussion board I could just modify the script to run stand alone.

If you're up for that then let me know i'll get straight to it :)

Dan
 

cyberphant0m

Member
Oct 21, 2003
99
0
0
DannyBoy, writing a birthday script would be very easy, the only problem we're facing, is getting the birthday field from user's profiles so that it can be processed by the script.

Also, here's a small idea for the API...

Rather than having each piece of the user's profile in a seperate variable, you could have it all in an associative array. Then you could split up the getUser() method into fillUser($username) which fills in the array with the data, then you could have the getUser() which simply returns the array.

IMHO, this would be a "better" way of doing it... Not sure if performance improves with one way or the other... if anyone wants to test this out somehow...
 

jonmullen

Platinum Member
Jun 17, 2002
2,517
0
0
Originally posted by: cyberphant0m
DannyBoy, writing a birthday script would be very easy, the only problem we're facing, is getting the birthday field from user's profiles so that it can be processed by the script.

Also, here's a small idea for the API...

Rather than having each piece of the user's profile in a seperate variable, you could have it all in an associative array. Then you could split up the getUser() method into fillUser($username) which fills in the array with the data, then you could have the getUser() which simply returns the array.

IMHO, this would be a "better" way of doing it... Not sure if performance improves with one way or the other... if anyone wants to test this out somehow...

Are you wanting to be able to get just one field at a time? Cuz the getUser() method now does return an array. But, yah I am planning to update the API to fetch just one field if required...that should save some time from running a bunch of regexp's. But thats really not the delay, the delay some from the two pages it has to wait on AT for to get the profile. One page to link a username to a userid and then requesting the profile based on the userid.
 

Templeton

Senior member
Oct 9, 1999
467
0
0
It looks like you are opening a new connection to the server and grabbing the entire profile for each peice of profile data you want to populate. You'd be much better off reading the profile data once from the server and parsing it all at once. You are already holding onto the contents in the object, you just need to make use of this in getProfileValue function.
 

jonmullen

Platinum Member
Jun 17, 2002
2,517
0
0
Originally posted by: Templeton
It looks like you are opening a new connection to the server and grabbing the entire profile for each peice of profile data you want to populate. You'd be much better off reading the profile data once from the server and parsing it all at once. You are already holding onto the contents in the object, you just need to make use of this in getProfileValue function.

I already noticed that, infact I just uploaded an updated version that I am calling 0.6. If fixes that problem of redundant calls by only fetching the profile if $contents is empty or contents holds the profile for a different ID. You should check it out I am getting a dramatic speed improvement. Its still not super fast but we have to remember that to go from a user name to a profile it takes a min. of two calls to the anandtech server.

Edit:

Lastly, the getUser() method now has an optional
value to specify what kind of array you want it to
return. The options are 'ASSOC' to get an array
indexed by the field name. 'NUM' to get an array
indexed by numbers starting with 0 ex. $returned[0].
The last option is 'BOTH' and is also the default
this will return an array where the first half is an
'NUM', followed by an 'ASSOC' array. This options should
probally not be used except in development, as it will
speed things up a bit to just get one kind of array back.