PHP 5.3

Issue No. 188





Reported By

Moises Alonso








30/Oct/14 8:29 AM EDT


31/Oct/2014 5:45 AM EDT


Hi, Great great job but I have a compatibility problem if I install php 5.4. Is there a way or trick to use the php api with php 5.3?

Closing Comment

For support, email directly and leave the issue tracker for bugs and new features only. If you email the code that is not working, I will take a look at it.


1. Erik Berg 30/Oct/2014 at 8:52 AM EDT

Do you mean the example PHP code does not work when used with PHP 5.3? The example code listings are just examples. The xmlstats API will respond to any well-formed HTTPS request. Whether you use PHP 5.3, 5.6, or another language altogether, as long as the request is valid the server will return the same response.

2. Moises Alonso 30/Oct/2014 at 8:59 AM EDT

I'm trying to find the problem as your php code works on all other systems I have (all php 5.4) except my production system which has every requirement shown at php api home page except php 5.4. The command "curl -H "Authorization: Bearer xxxxx" /nba/boxscore/20141029-milwaukee-bucks-at-charlotte-hornets.json" works but your php code replies with: PHP Warning: fopen(): HTTP request failed! HTTP/1.1 403 Forbidden in /home/tenkion/public/ on line 48 PHP Warning: fopen(compress.zlib:// failed to open stream: operation failed in /home/tenkion/public/ on li ne 48 handle error...

3. Erik Berg 30/Oct/2014 at 9:15 AM EDT

When the server responds with a 4xx error code (e.g., 403), it indicates a problem with your request. I think you will be able to solve this pretty quickly if you print the entire error message. Replace 'print "handle error...\n"' with: // handle error, check $http_response_header for HTTP status code, etc. if ($fh) { $xmlstats_error = json_decode(stream_get_contents($fh)); printf("Server returned %s error along with this message:\n%s\n", $xmlstats_error->error->code, $xmlstats_error->error->description); } else { print "A problem was encountered trying to connect to the server!\n"; print_r(error_get_last()); }

4. Moises Alonso 30/Oct/2014 at 9:21 AM EDT

you are right, is a problem with my debian server, but I don't know how to find it.

5. Moises Alonso 30/Oct/2014 at 10:49 AM EDT

got no clues from error_get_last: A problem was encountered trying to connect to the server! Array ( [type] => 2 [message] => fopen(compress.zlib:// fail ed to open stream: operation failed [file] => /home/tenkion/public/ [line] => 48 )

6. Moises Alonso 31/Oct/2014 at 4:15 AM EDT

Hi Erik, As you say 403 could be a problem with my request, but if the same code is working in other enviroment I think the problem is the environment. Don't you think so?