Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[php] Perfect World API class + examples

Junior Spellweaver
Joined
Dec 11, 2010
Messages
101
Reaction score
110
I was working on this php-based Perfect World API months ago. Now that I have time again, I decided to pick this project of mine again...and then just decided to rewrite everything into a better system all today.

So I proudly present PerfectWorldAPI class in php. This php class will help you by doing almost everything for you. Creating accounts, logging in, getting user data, user characters, GM lists, etc. As well as auto-filtering when you create users or log in. This can easily fit into any small or large site for PW.

I recommend you use Zend Studio for Eclipse or a php IDE that can read all of the methods from the class. If you don't have that, you can muddle through the generated documentation.

  • In case I put the wrong link, here's the folder:

Steps you MUST follow to get it running
  • Go into /includes/ and open up classPerfectWorldAPI.php
  • Put in your database information into the provided areas (which are clearly documented)

When making your content, you must define the constant ROOT as the location that the files are to be pulled from. Then include the files as shown below. Examples show this as well.
PHP:
/* -------------------------------------------------- */
if ( !defined('ROOT') )
	define('ROOT', '/var/www/');
require_once(ROOT . 'includes/classPerfectWorldAPI.php');
/* -------------------------------------------------- */

// Your code goes here!

Q & A

Something is broken or it's not working!
Please give me the error. Sometimes I break code, don't test it, and then release it. Therefore if you have that problem, alert me immediately so I can fix it promptly.

What on earth is Monkey?
It's a library based on a programming language called Monkey, that I went and took a lot further with php. Including classes that definitely weren't in that language. One last thing, yes, the Monkey library is a dependency, so DON'T leave it out.

Is there going to be more functionality?
Yes! I'm happy to report that this is only one day of work. What if we expand that to two? : O

What if I see a security issue?
Point it out. I'll attempt to see if it's actually a security issue. If it is, I'll fix it promptly.

I read the license, I disagree with it.
That's fine, I really don't care.

I'd like to contribute to the project, where can I do that?
Here. It's pretty simple, write a response with the code in it. I'll review it and might add it.

Can I ask for a feature?
You can. Whether or not I'll be able to accomplish said feature is questionable.

Updates
Code:
2/12/2012 - rev. 1
- License agreement was changed to be more suited for websites and their footers.

2/13/2012
- Tons of bug fixes, including one to AddUser
- AddGMByUsername, AddGMByID Added
- Other methods that I've forgotten the name of added

2/13/2012 - rev. 1
- Quick fix at the broken code at the top of classPerfectWorldAPI.php

2/16/2012
- Fixed method LoginByEmail
- Optimzed method GetOnlineCharList
- Optimized and added parameters 'limit' and 'page' to method GetCharList

2/17/2012
- Fixed bad logic in UsernameExists and EmailExists
- Added method SetPassword

2/22/2012
- Deprecated GetOnlineCharList and GetOnlineCharacterList, SQL cannot work

11/20/2012
- Fixed error that could cause session to endlessly error-out until session cookie was deleted or expired
 
Last edited:
Junior Spellweaver
Joined
Dec 11, 2010
Messages
101
Reaction score
110
If anyone is already using this, I urge you to grab the new version. I addressed many, many, bugs I didn't see when I was in the process of writing it. I also cleaned up the logic around several areas pretty drastically. Which means it'll run just slightly faster than before.

I'm also going to put this up on Google code later today. Though I think you should stick to the release, it'll be up to you to decide if you want the most up-to-date version.

EDIT: I updated it again, bleh.
 
Last edited:
Junior Spellweaver
Joined
Dec 11, 2010
Messages
101
Reaction score
110
I don't know how many people use this, but I just updated the API class with a major bug fix. The bug could cause a session that has failed to verify it's fingerprint to repeatedly fail because all of the session data was not cleaned up. Aside from that I also put in the updated Monkey library.

I should note that I've not tested the new Monkey library with the API, so if you have problems, please tell me. I don't think I've made any radical changes, but I also don't remember what I did a few months back since I'm not running a version tracker on it.
 
Newbie Spellweaver
Joined
Feb 26, 2010
Messages
34
Reaction score
0
I will try to implement it I like things made ​​in php

note
Only have classes, I'll see how to implement interfaces :?:
 
Last edited:
Back
Top