Difference between revisions of "PHP Native API"

From ScarletDME
Jump to navigation Jump to search
 
(14 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
The PHP native API uses a socket connection to directly connect to an open and functioning QM API socket.
 
The PHP native API uses a socket connection to directly connect to an open and functioning QM API socket.
  
This single library file can be dropped in on any PHP compatible web server and allow developer to use a series of function calls to access a QM Database with all the functionality that the QMClient API allows.
+
This single PHP script file can be dropped in on any PHP compatible web server and allow developer to use a series of function calls to access a QM Database with all the functionality that the QMClient API allows.
  
'''Warning''' Active bug found, i believe username padding is not working, some odd length usernames may cause a QMERROR 3000 for line 902, when trying to write to $LOGINS. I'm working on it. [[User:Diccon|Diccon]] 19:36, 27 January 2009 (UTC)
+
It is currently in the developing Alpha stages:
  
'''Solved''' Fixed this, not 100% sure what was really happening, but i rewrote the way the login packet is constructed, to make it clearer. This fixed it. Go, Play [[User:Diccon|Diccon]] 18:41, 16 February 2009 (UTC)
+
Make sure you have followed the [[QM-API_Server|QM Client Server setup guide]]
  
It is currently in the Alpha stages:
+
==News==
It supports:
+
 
* Logon
+
*[[User:Diccon|Diccon]]  09:15, 25 June 2013‎ Gene kindly moved the code storage over to GIT. PHP API lib is now stored for download there. Again it still works well with ScarletDME and probably will work with modern Commercial QM if the protocol hasn't changed.
 +
 
 +
*[[User:Diccon|Diccon]] 11:05, 6 April 2009 (UTC) Development has been paused until JD3 is fully assessed and it is determined if QMCLient is to continue getting my attention. This lib still works, others are welcome to develop on the SVN repo. Ask for commit access.
 +
* [[User:Diccon|Diccon]] 15:27, 9 March 2009 (UTC) Conditional Handling code is in, needs proper testing. Now have 34/46 command done, QMCall and a few others will be last because they take a bit of time/effort.
 +
*[[User:Diccon|Diccon]] 18:41, 16 February 2009 (UTC) '''Solved''' Fixed this, not 100% sure what was really happening, but i rewrote the way the login packet is constructed, to make it clearer. This fixed it. Go, Play!
 +
*[[User:Diccon|Diccon]] 19:36, 27 January 2009 (UTC) <strike>'''Warning''' Active bug found, i believe username padding is not working, some odd length usernames may cause a QMERROR 3000 for line 902, when trying to write to $LOGINS. I'm working on it.</strike>
 +
 
 +
==How to use==
 +
[[#Download|Download]] from the GIT repo from below.
 +
 
 +
Place this file in the same directory as the file that intends to use it, or place it in the library path for your PHP configuration.
 +
 
 +
In your php code Enter the following line at the top
 +
  include "PHPQMLib.php"
 +
 
 +
The first you need to call the connect function, something like this;
 +
  qmconnect("my.qm.server.com", "4243", "testuser", "testpass", "QMTESTACCOUNT");
 +
or
 +
  qmconnect("192.168.1.1", "4243", "testuser", "testpass", "QMTESTACC");
 +
 
 +
You can now use the variety of PHPQM functions like qmread(),
 +
qmdelete(), etc as you wish.
 +
When you are done, for tidiness issue a;
 +
  qmdisconnect();
 +
command, tidlying closing the socket.
 +
 
 +
Each page/script will need to (re)connect. Connection persistence and pooling is
 +
a bit bigger than this simple lib for now.
 +
 
 +
Check out qmLastClause() QMPHPClient function to cater for commands
 +
hitting ELSE, LOCKED, etc conditions
 +
 
 +
Generally you can follow the QMClient docs in terms of server functionality.
 +
Using the below defines() as what is and is not implemented.
 +
Better PHP specific docs will be written later, when we go Beta
 +
 
 +
==Supported Features==
 +
QMPHPClient supports (24/46);
 +
* Qm Quit
 +
* GetError
 
* Set account
 
* Set account
 
* Open
 
* Open
 +
* Close
 
* Read
 
* Read
 +
* ReadL (Untested)
 +
* ReadLW (Untested/partial)
 +
* ReadU (Untested)
 +
* ReadUL(Untested/partial)
 +
* Select
 +
* ReadNext
 +
* ClearSelect
 +
* ReadList
 +
* Release
 
* Write
 
* Write
 +
* WriteU
 
* Delete
 
* Delete
 +
* DeleteU
 +
* Execute
 +
* Respond
 +
* Logon
 +
 +
==Download==
 +
If you want a copy, it is released under the LGPL (i.e. can be used within commercial products, but is GPL itself). It is available on github here:
  
If you want a copy, it is released under the LGPL (i.e. can be used within commercial products, but is GPL itself). It is available on the gpl.openqm Subversion repository;
+
https://github.com/geneb/PHPQMClient
  
[http://gpl.openqm.com/svn/qmvdb/PHPQMLib/trunk/ http://gpl.openqm.com/svn/qmvdb/PHPQMLib/trunk/]
+
==Todo Shortlist==
 +
# Design and handle Conditional Execution, e.g. ELSE, LOCKED, ERROR, etc
 +
# Finish implementing all simple commands/function (24/46 Done)
 +
# Clean up error reporting

Latest revision as of 12:00, 5 September 2016

The PHP native API uses a socket connection to directly connect to an open and functioning QM API socket.

This single PHP script file can be dropped in on any PHP compatible web server and allow developer to use a series of function calls to access a QM Database with all the functionality that the QMClient API allows.

It is currently in the developing Alpha stages:

Make sure you have followed the QM Client Server setup guide

News

  • Diccon 09:15, 25 June 2013‎ Gene kindly moved the code storage over to GIT. PHP API lib is now stored for download there. Again it still works well with ScarletDME and probably will work with modern Commercial QM if the protocol hasn't changed.
  • Diccon 11:05, 6 April 2009 (UTC) Development has been paused until JD3 is fully assessed and it is determined if QMCLient is to continue getting my attention. This lib still works, others are welcome to develop on the SVN repo. Ask for commit access.
  • Diccon 15:27, 9 March 2009 (UTC) Conditional Handling code is in, needs proper testing. Now have 34/46 command done, QMCall and a few others will be last because they take a bit of time/effort.
  • Diccon 18:41, 16 February 2009 (UTC) Solved Fixed this, not 100% sure what was really happening, but i rewrote the way the login packet is constructed, to make it clearer. This fixed it. Go, Play!
  • Diccon 19:36, 27 January 2009 (UTC) Warning Active bug found, i believe username padding is not working, some odd length usernames may cause a QMERROR 3000 for line 902, when trying to write to $LOGINS. I'm working on it.

How to use

Download from the GIT repo from below.

Place this file in the same directory as the file that intends to use it, or place it in the library path for your PHP configuration.

In your php code Enter the following line at the top

 include "PHPQMLib.php"

The first you need to call the connect function, something like this;

 qmconnect("my.qm.server.com", "4243", "testuser", "testpass", "QMTESTACCOUNT");

or

 qmconnect("192.168.1.1", "4243", "testuser", "testpass", "QMTESTACC");

You can now use the variety of PHPQM functions like qmread(), qmdelete(), etc as you wish. When you are done, for tidiness issue a;

 qmdisconnect();

command, tidlying closing the socket.

Each page/script will need to (re)connect. Connection persistence and pooling is a bit bigger than this simple lib for now.

Check out qmLastClause() QMPHPClient function to cater for commands hitting ELSE, LOCKED, etc conditions

Generally you can follow the QMClient docs in terms of server functionality. Using the below defines() as what is and is not implemented. Better PHP specific docs will be written later, when we go Beta

Supported Features

QMPHPClient supports (24/46);

  • Qm Quit
  • GetError
  • Set account
  • Open
  • Close
  • Read
  • ReadL (Untested)
  • ReadLW (Untested/partial)
  • ReadU (Untested)
  • ReadUL(Untested/partial)
  • Select
  • ReadNext
  • ClearSelect
  • ReadList
  • Release
  • Write
  • WriteU
  • Delete
  • DeleteU
  • Execute
  • Respond
  • Logon

Download

If you want a copy, it is released under the LGPL (i.e. can be used within commercial products, but is GPL itself). It is available on github here:

https://github.com/geneb/PHPQMClient

Todo Shortlist

  1. Design and handle Conditional Execution, e.g. ELSE, LOCKED, ERROR, etc
  2. Finish implementing all simple commands/function (24/46 Done)
  3. Clean up error reporting