mrteye / GDAX

API for GDAX: A service provided by Coinbase. (Unofficial API)
MIT License
18 stars 5 forks source link

Problem using Examples #1 #9

Closed Josh-123 closed 6 years ago

Josh-123 commented 6 years ago

I am new to this and just getting started. I am on a Mac, enabled Apache, PHP and installed MySQL. Installed composer (version 1.7-dev). Ran composer require mrteye/gdax without errors.

Added dir mrteyeGDAX (with its contents) to the working dir. Updated config.php file name and added api credentials.

Created index.php inside mrteyeGDAX dir and pasted Examples #1 code. I am getting the following errors

Fatal error: Uncaught Error: Class 'mrteye\Gdax\Api' not found in /Users/josh/Sites/bot/mrteyeGDAX/index.php:6 Stack trace: #0 {main} thrown in /Users/josh/Sites/bot/mrteyeGDAX/index.php on line 6

What am I doing wrong? Thanks

nalagg commented 6 years ago

did you run composer with config.php and credentials filled out? your folder structure should have:

vendor composer.json composer.lock config.php

and in your php file: ` include 'config.php';

use mrteye\Gdax\Api as Api; use mrteye\Gdax\Auth as Auth; // rest of code ...`

Josh-123 commented 6 years ago

I am not sure if I am running composer correctly.

From terminal I ran again composer require mrteye/gdax I didn't see vendor or composer.lock

So I navigated to that directory and ran the command again, still I don't see those dir and files I got this message after running: Joshuas-MacBook-Pro:mrteyeGDAX josh$ composer require mrteye/gdax Using version ^1.2 for mrteye/gdax ./composer.json has been updated Root package 'mrteye/gdax' cannot require itself in its composer.json Did you accidentally name your root package after an external package?

nalagg commented 6 years ago

this was the first step:

Installation

Copy the config.php.example file to config.php and place it in your document root. Add credentials for private API calls.

then From terminal run composer require mrteye/gdax

Josh-123 commented 6 years ago

Yes I did that as the first step

I have config.php with credentials

nalagg commented 6 years ago

then maybe this part is not getting the propper path? // Setup; All tests should be one level below doc root. if (! $docRoot = $_SERVER['DOCUMENT_ROOT']) { $docRoot = dirname(dirname(__FILE__)); } echo $docRoot; require_once "$docRoot/vendor/autoload.php"; require "$docRoot/config.php";

can you echo out the path to verify thats where these files reside?

Josh-123 commented 6 years ago

Am I running the composer right? I still don't have vendor directory. The test script I ran by creating a index.php in the installation directory. I tried running the index.php inside test directory but I got errors as I don't have vendor dir.

nalagg commented 6 years ago

that test directory wont work, compser has to create that dir vendor and a json file. can you run composer --version from terminal, what do you see?

Josh-123 commented 6 years ago

Composer version 1.7-dev (3c09c0ab2a4b1acc13807fb7ff012a18d67a3a38) 2018-02-08 19:46:07

nalagg commented 6 years ago

i have version 1.6.3, curious if theres something about dev.

Josh-123 commented 6 years ago

I ran this composer remove mrteye/gdax and now I am seeing vendor dir! I am going to re run require and see what happens

Josh-123 commented 6 years ago

I ran composer require and got this message

Joshuas-MacBook-Pro:mrteyeGDAX josh$ composer require mrteye/gdax Using version ^1.2 for mrteye/gdax ./composer.json has been updated Root package 'mrteye/gdax' cannot require itself in its composer.json Did you accidentally name your root package after an external package?

When I run the example #1 I get this error Fatal error: Uncaught Error: Class 'mrteye\Gdax\Api' not found in /Users/josh/Sites/bot/mrteyeGDAX/index.php:6 Stack trace: #0 {main} thrown in /Users/josh/Sites/bot/mrteyeGDAX/index.php on line 6

mrteye commented 6 years ago

It looks like you are trying to require mrteye/gdax twice. Where is the working directory you mentioned?

mrteye commented 6 years ago

If you see vendor...you probably do not need to run composer require anymore...Inside vendor should be mrteye/gdax. From there you could create the config.php and run the example in vendor/mrteye/gdax/test.

Josh-123 commented 6 years ago

I got it to work. I had to run composer from outside the directory

Now when I run index.php inside test dir, I see the output but in three places I see Invalid API Key.

I have entered the API keys correctly.

mrteye commented 6 years ago

Nice work. And thanks for trying out the API.

My guess is you are using the wrong API key. Are you using a key from sandbox or production, and does that pair with the server in the config file?

Josh-123 commented 6 years ago

API key is from production. Not sure how to get API key for sandbox.

Josh-123 commented 6 years ago

I got it working! Thanks a lot for all your help!