WooCommerce Rest API没有得到卷曲响应

时间:2019-03-08 12:58:48

标签: php wordpress woocommerce postman woocommerce-rest-api

当我尝试在Postman中运行WooCommerce API时,它向我显示json的响应,但是当我尝试运行WooCommerce API时,它将显示CURL,它没有任何响应和加载,任何人都可以吗帮我这是什么问题?

$header = array(
    'Authorization: Basic Y2tfZmE1NWQ1N2RjNmY1xxxxxx'
    );  
    $ch = curl_init();  
    curl_setopt($ch, CURLOPT_URL,'https://xxxxx.com//wp-json/wc/v3/products/attributes');
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    //curl_setopt($ch, CURLOPT_POST, 0);
    //curl_setopt($ch, CURLOPT_POSTFIELDS, "postvar1=value1&postvar2=value2&postvar3=value3");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $server_output = curl_exec($ch);
    if (curl_error($ch)) {
    $error_msg = curl_error($ch);
    echo $error_msg; die;
    }
    echo "<pre>";
    print_r($server_output);
    die;
    curl_close($ch);

0 个答案:

没有答案