【问题标题】:Rest API on executed give errorRest API 执行时给出错误
【发布时间】:2015-09-01 07:11:52
【问题描述】:

我正在尝试使用 woo commerce 提供的 rest API 添加产品,但它给了我以下错误。

致命错误:未捕获的异常“异常”,带有消息“WooCommerce REST API 客户端需要 cURL PHP 扩展。”在 C:\Apache24\htdocs\WooCommerce-REST-API-Client-Library-master\lib\woocommerce-api\class-wc-api-client.php:86 堆栈跟踪:#0 C:\Apache24\htdocs\WooCommerce -REST-API-Client-Library-master\example\example.php(11): WC_API_Client->__construct('http://www.woot...', 'ck_xxxxxxx...', 'cs_xxxxxxx...', 数组) #1 {main} 在第 86 行的 C:\Apache24\htdocs\WooCommerce-REST-API-Client-Library-master\lib\woocommerce-api\class-wc-api-client.php 中抛出

require_once( 'C:/Apache24/htdocs/WooCommerce-REST-API-Client-Library-master/lib/woocommerce-api.php' );

$options = array(
'ssl_verify'      => false,
);

try {

    $client = new WC_API_Client( 'http://www.example.com/demo/wpinsttalledlocation', 'ck_xxxxxxxxxxxxxxxxxxxxxx', 'cs_xxxxxxxxxxxxxxxxxxxxxxxxxx', $options );


    } catch ( WC_API_Client_Exception $e ) {

    echo $e->getMessage() . PHP_EOL;
    echo $e->getCode() . PHP_EOL;

    if ( $e instanceof WC_API_Client_HTTP_Exception ) {

        print_r( $e->get_request() );
        print_r( $e->get_response() );
    }
}

【问题讨论】:

  • 您是否安装了 cURL PHP 扩展
  • 不,你能帮我吗
  • 对不起,我忍不住一个简单的google search 应该可以帮助你。
  • 它已经安装了我已经删除了 php.ini 中的扩展,以为是另一个进程,但仍然出现同样的错误
  • 您是否重新启动了服务器软件?

标签: php wordpress api rest curl


【解决方案1】:

你需要安装 php-curl。

sudo apt-get install php5.6-curl (or your version php)

然后,重新启动 apache。

sudo service apache2 restart

【讨论】:

    猜你喜欢
    • 2015-03-10
    • 2013-09-10
    • 2020-01-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-09
    • 1970-01-01
    • 2017-07-13
    相关资源
    最近更新 更多