Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
en:comet:cometql [2017/01/19 09:09] levhav |
en:comet:cometql [2017/09/01 07:18] levhav |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | <rst>EN::002-API::002-CometQL::004-CometQL API</rst> | ||
+ | <rst>Header: CometQL API</rst> | ||
+ | |||
====== CometQL ====== | ====== CometQL ====== | ||
Line 39: | Line 42: | ||
<note tip>[[en:comet:cometql:cli|Here you can test source code based on PHP with CometQL]] using for online command prompt implementation.</note> | <note tip>[[en:comet:cometql:cli|Here you can test source code based on PHP with CometQL]] using for online command prompt implementation.</note> | ||
+ | |||
+ | An example of connecting to a comet server from php. | ||
+ | <code php> | ||
+ | $dev_id = "15"; // Used as login | ||
+ | $dev_key = "lPXBFPqNg3f661JcegBY0N0dPXqUBdHXqj2cHf04PZgLHxT6z55e20ozojvMRvB8"; // Used as a password | ||
- | <note important>Also are cases when you can’t use MySQL protocol to connecting comet server. For these cases you can send commands to comet server by HTTP/HTTPS. Read the article [[en:comet:cometql:HTTP|sending CometQL queries by HTTP]].</note> | + | // The connection looks like we connected to the database. You can use the functions to work with mysql |
+ | // But in fact you are connecting to the comet server. | ||
+ | $link = mysqli_connect("app.comet-server.ru", $dev_id, $dev_key, "CometQL_v1"); | ||
+ | if(!$link) | ||
+ | { | ||
+ | die("Could not create connection with CometQL"); | ||
+ | } | ||
+ | $result = mysqli_query ( $link, "show status" ); | ||
+ | if(mysqli_errno($link) != 0) | ||
+ | { | ||
+ | echo "Error code:<a href='https://comet-server.com/wiki/doku.php/en:comet:cometql:error' target='_blank' >".mysqli_errno($link)."</a>"; | ||
+ | echo "Error text:<a href='https://comet-server.com/wiki/doku.php/en:comet:cometql:error' target='_blank' >".mysqli_error($link)."</a>"; | ||
+ | exit; | ||
+ | } | ||
+ | |||
+ | while($row = mysqli_fetch_assoc($result)) | ||
+ | { | ||
+ | echo "<pre>"; | ||
+ | var_dump($row); | ||
+ | echo "</pre><br>"; | ||
+ | } | ||
+ | |||
+ | </code> | ||
====== Table description ====== | ====== Table description ====== | ||
Line 86: | Line 116: | ||
Input channel name “pipe _name” and click “subscribe”. | Input channel name “pipe _name” and click “subscribe”. | ||
<html> | <html> | ||
- | <iframe src="//comet-server.ru/doc/example/7/subscriptionTest.php" width="910px"></iframe> | + | <iframe src="//comet-server.com/doc/example/7/subscriptionTest.php" width="910px"></iframe> |
</html> | </html> | ||
Now perform with online command prompt insert-query with pipes_messages and check the result. | Now perform with online command prompt insert-query with pipes_messages and check the result. | ||
Line 113: | Line 143: | ||
Input channel name “web_admins” and click “subscribe”. | Input channel name “web_admins” and click “subscribe”. | ||
<html> | <html> | ||
- | <iframe src="//comet-server.ru/doc/example/7/subscriptionTest.php" width="910px"></iframe> | + | <iframe src="//comet-server.com/doc/example/7/subscriptionTest.php" width="910px"></iframe> |
</html> | </html> | ||
Now perform query again and you will see that amount of subscribers are increase. | Now perform query again and you will see that amount of subscribers are increase. | ||
Line 194: | Line 224: | ||
===== Table users_time ===== | ===== Table users_time ===== | ||
- | The table users_time contains data about users were online. This table is available only for reading. Data timing stores in UNIX-time. | + | The table users_time contains data about when users were online. This table is available only for reading. Data timing stores in UNIX-time. |
<code sql> | <code sql> | ||
mysql> select * from users_time where id in( 2, 3, 145); | mysql> select * from users_time where id in( 2, 3, 145); | ||
Line 235: | Line 265: | ||
===== Other information ===== | ===== Other information ===== | ||
- | * [[en:comet:cometql:cli|Example of using CometQL based on PHP;]] | ||
* [[en:comet:cometql-bash-example|Example of sending messages from bash.]] | * [[en:comet:cometql-bash-example|Example of sending messages from bash.]] | ||
* [[en:comet:cometql:error|Error code in CometQL]] | * [[en:comet:cometql:error|Error code in CometQL]] | ||
* [[en:comet:javascript_api:pipe-types|Reserved channel names]] | * [[en:comet:javascript_api:pipe-types|Reserved channel names]] | ||
* [[en:comet:javascript_api|JavaScript API]] | * [[en:comet:javascript_api|JavaScript API]] | ||
- | * [[en:comet:testhosting|Why the script runs on the local machine and does not work on hosting?]] | + | * [[en:comet:dev_id|What it is and why do we need "A public developer token" and "Secret developer key?"]] |
- | * [[en:comet:faq:public_key|What it is and why do we need "A public developer token" and "Secret developer key?"]] | + | |
- | * [[en:comet:faq:send-message-to-pipe|How to send a message to an arbitrary channel and how to then get on another page?]] | + | |
- | * [[en:comet:faq:realtime-users-list|How to implement a mechanism for tracking users entering the site. That is a list of visitors updated on the "fly"?]] | + | |
====== Reserved channels names ====== | ====== Reserved channels names ====== |