HTML and CSS Reference
In-Depth Information
user information for presence channels . We just want to use the basic event triggering
24
functionality in the post_comment.php file so we need to download the Pusher PHP library 25
( direct zip file download ) .
26
Once you've downloaded this zip file, unzip it into the directory along with your other files. Your
file structure will now look something like this:
index.php
css (dir)
images (dir)
post_comment.php
pusher_config.php
Persistence.php
squeeks-Pusher-PHP (dir) including lib (dir) with Pusher.php
An event can be triggering in just a few lines of code:
<?php
require ( 'squeeks-Pusher-PHP/lib/Pusher.php' );
require ( 'pusher_config.php' );
$pusher = new Pusher ( APP_KEY , APP_SECRET , APP_ID );
$pusher -& gt ; trigger ( 'comments-1' , 'new_comment' , array (
"comment_post_ID" =& gt ; 1 ,
"date" =& gt ; "Tue, 21 Feb 2012 18:33:03 +0000" ,
"comment" =& gt ; "The realtime Web rocks!" ,
"comment_author" =& gt ; "Phil Leggetter"
));
?>
However, we need to apply a some additional logic before we trigger the event:
Check that the comment was added.
Extract the unique comment identifier from the $added array.
Search WWH ::




Custom Search