-2

The following function works fine locally, but causes a blank page when the function is called on the Ubuntu VM. message_room is properly define in HipChat.php (again, it works as expected locally).

require 'HipChat.php';

define('HIPCHAT_APIKEY', 'xxx');
define('HIPCHAT_NAME', 'Assets');
define('HIPCHAT_ROOM', 'Assets');

function hipchatDump ($message) {
    $hc = new HipChat\HipChat(HIPCHAT_APIKEY);
    try {
        $hc->message_room(HIPCHAT_ROOM, HIPCHAT_NAME, $message, false, 'yellow', 'text');
    } catch (Exception $e) {
        echo 'Caught exception: ',  $e->getMessage(), "\n";
    }
}

The command php --version produces the following on each machine:

Macbook:

PHP 5.4.17 (cli) (built: Sep 12 2013 23:14:23) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

Ubuntu VM:

PHP 5.5.3-1ubuntu2.1 (cli) (built: Dec 12 2013 04:24:35) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
    with Zend OPcache v7.0.3-dev, Copyright (c) 1999-2013, by Zend Technologies

The try/catch is not outputting anything. I've narrowed the issue down to the line:

$hc->message_room(HIPCHAT_ROOM, HIPCHAT_NAME, $message, false, 'yellow', 'text');

From what I can tell, nothing that has changed in PHP5.5 should be causing this to fail based on the PHP version. Any ideas why this works on one machine and not the other?

UPDATE

It appears the initial problem was that cURL was not installed. After installing it and restarting the apache service, the original error in the Apache log file is gone, but now I see this:

[Wed Jan 15 17:14:48.767984 2014] [:error] [pid 5886] [client 172.16.3.77:65381] PHP Fatal error:  Call to undefined function HipChat\\json_decode() in /var/www/assets/scripts/php/HipChat/HipChat.php on line 240, referer: http://myurl/

My Ubuntu version is 13.10

dropknow1edge
  • 55
  • 1
  • 7
  • Can you view your Apache logs (assuming you're using Apache)? – Scopey Jan 16 '14 at 00:47
  • @Scopey This is the error I'm getting from the Apache log: `[Wed Jan 15 17:01:31.438401 2014] [:error] [pid 27153] [client 172.16.3.77:65162] PHP Fatal error: Call to undefined function HipChat\\curl_init() in /var/www/assets/scripts/php/HipChat/HipChat.php on line 185, referer: http://myurl` I install php5-curl on the VM, but am still seeing the same error. – dropknow1edge Jan 16 '14 at 01:01
  • @Scopey Please see my latest update. After restarting Apache, the curl error is gone, but I'm now getting an error saying that json_decode is undefined as well – dropknow1edge Jan 16 '14 at 01:17
  • Please check http://stackoverflow.com/questions/18239405/php-fatal-error-call-to-undefined-function-json-decode and see if this applies to you. (`sudo apt-get install php5-json` might fix it for you!) – Scopey Jan 16 '14 at 01:25
  • @Scopey it did indeed! Please add an answer if you'd like – dropknow1edge Jan 16 '14 at 01:37

1 Answers1

0

The answer is twofold.

Firstly the cURL library is missing, and then the JSON library is missing.

You can find error messages for these issues by checking your error logs which are listed in the phpinfo().

Simply installing these two packages resolves the issue:

sudo apt-get install php5-curl

sudo apt-get install php5-json

Scopey
  • 6,269
  • 1
  • 22
  • 34