PHP script works on mac but not on windows

I am utilizing parse.com and the PHP library for interacting with the framework is only working for me on a mac using MAMP, but on windows using XAMPP or WAMP, it fails for the same reason each time. Below is the function called each time a connection is made to parse. When ran on windows, $responseCode = 0 and $response is false. When I run it on my Mac, $responseCode = 200 and $response returns the json data it is suppose too. What is going on? Why would the different platforms be causing a failure?

public function request($args){
        $isFile = false;
        $c = curl_init();
        curl_setopt($c, CURLOPT_TIMEOUT, 30);
        curl_setopt($c, CURLOPT_USERAGENT, 'parse.com-php-library/2.0');
        curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($c, CURLINFO_HEADER_OUT, true);
        if(substr($args['requestUrl'],0,5) == 'files'){
            curl_setopt($c, CURLOPT_HTTPHEADER, array(
                'Content-Type: '.$args['contentType'],
                'X-Parse-Application-Id: '.$this->_appid,
                'X-Parse-Master-Key: '.$this->_masterkey
            ));
            $isFile = true;
        }
        else if(substr($args['requestUrl'],0,5) == 'users' && isset($args['sessionToken'])){
            curl_setopt($c, CURLOPT_HTTPHEADER, array(
                'Content-Type: application/json',
                'X-Parse-Application-Id: '.$this->_appid,
                'X-Parse-REST-API-Key: '.$this->_restkey,
                'X-Parse-Session-Token: '.$args['sessionToken']
            ));
        }
        else{
            curl_setopt($c, CURLOPT_HTTPHEADER, array(
                'Content-Type: application/json',
                'X-Parse-Application-Id: '.$this->_appid,
                'X-Parse-REST-API-Key: '.$this->_restkey,
                'X-Parse-Master-Key: '.$this->_masterkey
            )); 
        }
        curl_setopt($c, CURLOPT_CUSTOMREQUEST, $args['method']);
        $url = $this->_parseurl . $args['requestUrl'];

        if($args['method'] == 'PUT' || $args['method'] == 'POST'){
            if($isFile){
                $postData = $args['data'];
            }
            else{
                $postData = json_encode($args['data']);
            }

            curl_setopt($c, CURLOPT_POSTFIELDS, $postData );
        }

        if($args['requestUrl'] == 'login'){
            $urlParams = http_build_query($args['data'], '', '&');
            $url = $url.'?'.$urlParams;
        }
        if(array_key_exists('urlParams',$args)){
            $urlParams = http_build_query($args['urlParams'], '', '&');
            $url = $url.'?'.$urlParams;
        }

        curl_setopt($c, CURLOPT_URL, $url);

        $response = curl_exec($c);
        $responseCode = curl_getinfo($c, CURLINFO_HTTP_CODE);

        $expectedCode = '200';
        if($args['method'] == 'POST' && substr($args['requestUrl'],0,4) != 'push'){
            $expectedCode = '201';
        }

        if($expectedCode != $responseCode){
            //BELOW HELPS WITH DEBUGGING
                    //echo "VAR DUMP:";
                    //var_dump($response);      
        }

        return $this->checkResponse($response,$responseCode,$expectedCode);
    }

private function checkResponse($response,$responseCode,$expectedCode){
        //TODO: Need to also check for response for a correct result from parse.com
        if($responseCode != $expectedCode) {

            $error = json_decode($response);
            $this->throwError($error->error,$error->code);
        }
        else{
            //check for empty return
            if($response == '{}'){
                return true;
            }
            else{
                return json_decode($response);
            }
        }
    }
}

Error:

[23-Jan-2013 19:57:45 UTC] PHP Notice:  Trying to get property of non-object in C:\wamp\www\firecom\parse\parse.php on line 180

[23-Jan-2013 19:57:45 UTC] PHP Notice:  Trying to get property of non-object in C:\wamp\www\firecom\parse\parse.php on line 180

[23-Jan-2013 19:57:45 UTC] PHP Fatal error:  Uncaught ParseLibraryException: [0]: thrown in C:\wamp\www\firecom\parse\parse.php on line 169

Answers


Replace:

$response = curl_exec($c);

With:

if( ! $response = curl_exec($c) ) {
    die(curl_error($c));
}

Or substitute whatever error-handling code you like.

http://ca2.php.net/manual/en/function.curl-error.php


Need Your Help

Making nice, scalable rows using left-floated div tags of variable height

jquery css html javascript-events css-float

I want to display a series of elements in nice, neat, table-ish rows. Each element will have a set width but will have a variable height (determined automatically by the content inside that elemen...

Java results differ for (int)Math.pow(2,x) and 1<<x

java bitwise-operators bit-shift

Why do the following two operations yield different results in Java for x = 31 or 32 but the same results for x=3?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.