More PHP wrapper issues?

I have serious issues using the PHP wrapper.

e.g.:

$plan = $client->getPlan('FREE'); $allplans = $client->getPlans();

I have 2 plans configured, I would expect the second call return all plans instead of the plan previously fetched using the first call.
What's going on?

  1. I am using PHP Version 5.3.10

  2. I found the solution to this problem.
    There is a major bug in CurlAdapter.php.

    in the 'else' part where your're checking if the resource exists you forgot to pass the url

    curl_setopt($this->_resource, CURLOPT_URL, $url);

    the code should be:

        if (!$this->_resource) {
            $this->_resource = curl_init($url);
            $userAgent = (isset($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] . ' - CheddarGetter_Client PHP' : 'CheddarGetter_Client PHP';
            $options = array(
                CURLOPT_RETURNTRANSFER => true,
                CURLOPT_SSL_VERIFYPEER => false,
                CURLOPT_SSL_VERIFYHOST => false,
                CURLOPT_CONNECTTIMEOUT => 10,
                CURLOPT_TIMEOUT => 60,
                CURLOPT_USERAGENT => $userAgent,
                CURLOPT_USERPWD => $username . ':' . $password,
                CURLOPT_FOLLOWLOCATION => true,
                CURLOPT_MAXREDIRS => 10             
      );
            foreach ($options as $key=>$val) {
                curl_setopt($this->_resource, $key, $val);
            }
        } else {
            curl_setopt($this->_resource, CURLOPT_USERPWD, $username . ':' . $password);
            curl_setopt($this->_resource, CURLOPT_HTTPGET, true);
      curl_setopt($this->_resource, CURLOPT_URL, $url);
        }
    
  3. to be frank I think the code in there is a mess... excuse me...

    I think you should create the context without url parameter if the resource doesn't exist, then init the context with it's default parameters.
    After that you should pass the request specific parameters like the url, password, user and post parameters.

  4. I see. Thanks for pointing out the problem. The PHP wrapper is open source and the new curl adapter was contributed by the community in a recent version. Rather than making accusatory comments here or here (or anywhere), you might consider forking the repo and contributing the fix.

    We're here to help and make every effort to do so. We will continue to do so despite your inflammatory comments though it is my hope that our discourse proceeds in a more civil manner.

  5. I did not mean to be accusatory, i wanted to be helpfull.
    I found a nasty bug, you could be a little more thankfull.

  6. ra.keizer closed this discussion on 26 May, 2012 03:12 PM.

Discussions are closed to public comments.
If you need help with Cheddar please start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions