kloon / WooCommerce-REST-API-Client-Library

A PHP wrapper for the WooCommerce REST API
GNU General Public License v3.0
356 stars 175 forks source link

Not getting any response from the API #219

Closed johnmarlow007 closed 7 years ago

johnmarlow007 commented 7 years ago

Hello. First of all, congrats and thanks for your work! I have enabled the API in my shop and generated the keys then I tried to use it from an external app by installing the Rest Api Library and using the code but the script does not return anything at all. Sometimes I get a 500 Server error. I am struggling with this for almost a week now and getting pretty desperate. I even installed a self-signed SSL, but no change...

This is a sample of code I use: <?php // Include the client library require_once 'WooAPILibrary/lib/woocommerce-api/class-wc-api-client.php'; $consumer_key = 'ck_xxx'; // Add your own Consumer Key here $consumer_secret = 'cs_yyy'; // Add your own Consumer Secret here $store_url = 'http://www.mysite.com`'; // Add the home URL to the store you want to connect to here // Initialize the class $wc_api = new WC_API_Client( $consumer_key, $consumer_secret, $store_url ); print_r($wc_api->index->get() ); ?> I have tried many other variations with no luck either.

I also have to mention that the urls http://www.myshop.com/wc-api/v1/ http://www.myshop.com/wc-api/v2/ http://www.myshop.com/wc-api/v3/ all display various json results, so that makes me think that the API itself works.

Can you please tell me what the heck am I doing wrong? Thank you so much. Andy.

kloon commented 7 years ago

It is possible that something on your site it triggering a error and causing the site to 500 when you call an endpoint.

Perhaps also give the official library a go and see if that works https://github.com/woocommerce/wc-api-php

kdenno commented 6 years ago

Library works when ck and cs keys are for Admin and returns the std class object but when keys are for a different user returns Error: You do not have permission to read this product even when user has read/write privileges. and goes ahead to create the product in the database $client->products->create($data);