Pawan
Pawan

Reputation: 179

Fatal error: Class 'HttpResponse' not found even after pecl_http loaded in php.ini

I have installed and loaded PECL http extension.

I have added these lines in php.ini:

extension=raphf.so
extension=propro.so
extension=http.so

And I see the following being added in the output of

phpinfo()

HTTP Support enabled, Extension Version 2.0.4

libz 1.2.5 1.2.5

libcurl 7.24.0 7.24.0

libevent disabled disabled

But when I try to use the class HttpResponse I am getting the error:

Fatal error: Class 'HttpResponse' not found in RequestHandler.php on line 21

Can anyone please guide to what I have missed.

Upvotes: 0

Views: 1116

Answers (2)

Pawan
Pawan

Reputation: 179

I figured it out. YAY!!

I was installing pecl_http version 2 and testing methods from version 1. Version 2 has a completely different API than version 1. Who would have guessed :)

Upvotes: 1

Rowan Shield - NH
Rowan Shield - NH

Reputation: 61

What about using code that doesn't require the PECL extension?

For example this is something I used to retrieve a result back from a specially designed aspx file:

function getLoginToken($dashboardUrl, $dashboardUsername, $dashboardPassword)
{
    $url = "{$dashboardUrl}GetLoginToken.aspx";
    $data = array('dashboardUsername' => $dashboardUsername,
            'dashboardPassword' => $dashboardPassword);
    $options = array(
            'http' => array(
                'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
                'method'  => 'POST',
                'content' => http_build_query($data),
            ),
            );

    $context  = stream_context_create($options);
    $result = file_get_contents($url, false, $context);
    return $result;
}

Upvotes: 0

Related Questions