jasonknight / woocommerce-json-api

A simple, Abstract JSON API for Wordpress' Awesome Plugin: WooCommerce
58 stars 21 forks source link

Is it possible to test the plugin using cUrl method? #61

Closed StierTechstars closed 10 years ago

StierTechstars commented 10 years ago

First of all, thanks for this plugin! It really looks promising since wooCommerce lacks jSon support.

I have installed installed and activated the plugin, I'm planning to test the plugin using cUrl method just to get a grasp of the concept. But I can't seem to make it work.

I tried curl -X POST -H "Accept: application/json" -H "Content-Type: application/json" -d '{action:"woocommerce_json_api",proc: "get_system_time", arguments: {token: "123",},}' http://localhost/test/

I also tried using the test folder, which also did not work, I get an error that says Invalid API User.

I probably just have the wrong API Page. Can you help?

jasonknight commented 10 years ago

In order to run the tests in the test directory you need to edit tests/config.php and input your vals.

These tests are using the PHP cURL.

I am sorry that this requires a bit of rigging to get going.

StierTechstars commented 10 years ago

I'm just trying to learn things. :) And thanks for the really fast reply. I'm amaze.

So, here's my config.php file

<?php $url = 'http://localhost/test/wp-content/plugins/api.php'; $token = '1234';

What else should I put there to run the tests? Because I'm still getting the Not a valid API User.

BTW, I'm using my terminal to execute the test files.

jasonknight commented 10 years ago
<?php
$username = 'myuser';
$password = 'mypassword';

If you want to test username/password authentication...

I think there are like 1-2 tests that use those settings. But nothing from suite.php

jasonknight commented 10 years ago

You also need to setup the user, and make sure the user has perms for the request. You actually have to press the save button on the user profile. Make sure the token is set there as well.