“PHP Fatal error: Class 'HttpRequest' not found”

前端 未结 2 1775
Happy的楠姐
Happy的楠姐 2020-11-28 12:07

I\'ve been stuck trying to solve this problem in many ways, reading a lot of posts but still having no luck. I work on a Mac, OSX 10.7 Lion, and I\'m writing a plugin for a

相关标签:
2条回答
  • 2020-11-28 12:42

    The class HttpRequest is provided by v1 of this PECL extension.

    Re-install via: $ pecl install -f pecl_http-1.7.6

    You can find documentation for v2 here, though: https://mdref.m6w6.name/http

    0 讨论(0)
  • 2020-11-28 12:54

    alternatively, in case you cannot control certain environmental variables or install packages, you might try using curl which should return a json object (below is a working snippet of a google api call).

    $url = 'https://www.googleapis.com/oauth2/v3/tokeninfo?id_token=TOKEN_DATA_123';
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $response = curl_exec($ch);
    $json = json_decode($response, true);
    curl_close($ch);
    print_r($json);
    $userEmail = $json["email"];
    
    0 讨论(0)
提交回复
热议问题