So, I am trying to use the coinbase API. I'm attempting a simple test to see if I can make it work, but I'm getting various composer errors.
Currently, I am getting unexpected t 'use' for this code:
use Coinbase\Wallet\Client;
use Coinbase\Wallet\Configuration;
$apiKey = 'public';
$apiSecret = 'private';
$configuration = Configuration::apiKey($apiKey, $apiSecret);
$client = Client::create($configuration);
$spotPrice = $client->getSpotPrice();
echo $spotPrice;
So, are my use statements in the wrong place? Ive tried them outside the index function and outside the class. Both yield completely different sets of results than this.
Outside of the Keks class, I get
Fatal error: Class 'Coinbase\Wallet\Configuration' not found in /home/content/61/11420661/html/beta/application/controllers/keks.php on line 15
And inside the class but outside the index() function I get
Fatal error: Trait 'Coinbase\Wallet\Client' not found in >/home/content/61/11420661/html/beta/application/controllers/keks.php on line 4
Is there something wrong in my composer.json maybe?
The full controller is here: http://pastebin.com/4BjPP6YR
You cannot use "use" where you are using it.
The "use" keyword is either in front of a class definition to import other classes/interfaces/traits into it's own namespace, or it is inside the class (but not inside a method) to add traits to the class.
<?php
namespace Foo;
use Different\Class; // use can go here
class Bar {
use TraitCode; // use can go here
public function baz() {
$this->traitFunction('etc');
// use CANNOT go here
}
}
I'm using codeigniter when i try to use "use" keyword its throwing error within a method.
SO i just moved it to above class declaration.
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
use Auth0\SDK\Auth0;
class Home extends CI_Controller {
}
?>
Its working fine.
'WEB' 카테고리의 다른 글
Cisco AnyConnect Secure Mobility Client 4.5 Download Links (0) | 2019.03.24 |
---|---|
libmysqlclient.so.16 help (SOLVED) (0) | 2018.06.18 |
How to increase maximum POST variable in PHP? (0) | 2018.06.01 |
HTML STYLE CSS 인쇄시 페이지 기본 여백 설정하기. (0) | 2018.05.29 |
리눅스 문자셋(charset) 설정 (0) | 2018.05.17 |
<?php echo phpversion();
– VolkerK Oct 26 '15 at 10:19<?php echo phpversion();
to get the version. – VolkerK Oct 26 '15 at 10:22parse error: syntax error, unexpected 'use' (T_USE)
or is it something else? (If it is: what is before the code snippet you've posted?) – VolkerK Oct 26 '15 at 10:25