More PHP wrapper issues?

ra.keizer's Avatar

ra.keizer

25 May, 2012 04:19 PM

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. 1 Posted by ra.keizer on 25 May, 2012 04:36 PM

    ra.keizer's Avatar

    I am using PHP Version 5.3.10

  2. 2 Posted by ra.keizer on 25 May, 2012 07:23 PM

    ra.keizer's Avatar

    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. 3 Posted by ra.keizer on 25 May, 2012 07:26 PM

    ra.keizer's Avatar

    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. Support Staff 4 Posted by Marc Guyer on 25 May, 2012 09:34 PM

    Marc Guyer's Avatar

    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. 5 Posted by ra.keizer on 25 May, 2012 09:42 PM

    ra.keizer's Avatar

    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

28 Mar, 2024 10:45 PM
24 Jan, 2024 08:33 AM
11 Jan, 2024 07:13 AM
30 Nov, 2023 02:07 AM
22 Nov, 2023 08:41 AM