Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Cocomo & PHP


Level 1
I'm trying to use Cocomo with an existing PHP web site. But I
can't seem to get the classes to work. Any suggestions?

7 Replies


Level 10
Hi There,

I'm not the PHP expert here (Raff should be around tomorrow
to help answer) - but it seems what you're trying to do is create a
new room. Are you getting any error back here? A couple of things -
I think you need to log into the cocomo service, and here you're
only supplying your account URL (no username and password). It also
seems as though you need to supply a roomName, and optionally a
template from which to build a room.

Anyhow, as I say, I'm not the expert, just trying to suggest
some directions to try. Tomorrow, Raff should be able to be of more

hope that helps



In your example you don't login.

The correct sequence to create a room should be:

$pc_acccount = new CocomoAccount("");

$pc_account->login($username, $password);


/* or */

$pc_account->createRoom($roomName, $template);

The external authentication example for php shows you some
real code, but it's specific to external authentication.

Also, for each language, php included, there is a "main"
application (bottom of the script) that allow you to use the script
as a standalone (commandline) application to manage your account,
but it will also show how to use the different APIs.

In this particular case look at lines 613-614 for getting the
CocomoAccount object and line 629 for room creation.


Level 1
Hello Raff,

Now I receive two error messages. I'm not sure what I'm doing
wrong. Below are the error messages and the sample code. Your help
is very appreciated.

Parse error: parse error, expecting `T_OLD_FUNCTION' or
`T_FUNCTION' or `T_VAR' or `'}'' in
/home/www/ecyberview/cocomo/cocomo.php on line 35

Fatal error: Cannot instantiate non-existent class: cocomo in
/home/www/ecyberview/cocomo/index.php on line 114


Hmmm, I just tried your example and it works for me (apart
that you have an extra letter in the fist $pc_account - spelled

What version of PHP are you using ? I have developed and
tested with PHP 5. Not sure if it would work in PHP 4 (for sure the
error in line 35 is because PHP < 5 doesn't support 'const' -
you could try to change it to a variable and see how far you get)


Level 1
Ahh... I'm running PHP Version: 4.3.2

In the cocomo.php file, I changed the //private $authURL; to
var $authURL;

Now it doesn't like like like Line 56: if (Cocomo::$DEBUG)
echo "$resp\n";


As I said the code was written for PHP 5, that has been out
for a while now so I thought it was a safe bet 🙂

You need to do a little more to make it work on PHP 4 but
this maybe will help:

I think the things to look for are:

- Class constructors

- Method and properties visibility

- constants (do I use constant ? I don't remember 🙂

hope this helps, or maybe you could thing about updating to