2016-12-04 2 views
2

Coinbase API로 작업하기 위해 아래 코드를 잘못 이해할 수 있습니다. Composer에 Coinbase 의존성이 설치되어 있습니다. 이전에는 Coinbase 클래스가 설치되지 않았다는 오류가 발생했습니다. 이는 경로 때문이라고 생각했습니다. 더 이상 오류가 발생하지 않지만 코드가 실행되지 않습니다. 누구든지 도와 줄 수 있습니까?Coinbase API를 작동 시키려고 시도합니다.

<?php 
    require_once __DIR__ . '/usr/bin/vendor/autoload.php'; 
    use coinbase\coinbase; 

    //I've tried to run it both with and without the following 3 lines of code with no difference 
    ini_set('display_errors', 1); 
    ini_set('display_startup_errors', 1); 
    error_reporting(E_ALL); 


    $apiKey = 'XXX'; 
    $apiSecret = 'XXX'; 

    $configuration = Configuration::apiKey($apiKey, $apiSecret); 
    $client = Client::create($configuration); 

    $account = $client->getPrimaryAccount(); 
    echo 'Account name: ' . $account->getName() . '<br>'; 
    echo 'Account currency: ' . $account->getCurrency() . '<br>'; 
    ?> 

답변

1

예의 경우 the Coinbase repository에 네임 스페이스 문제가 있습니다. PHP가 Configuration 또는 Client 클래스를 찾을 수 없습니다.

<?php 

use Coinbase\Wallet\Client; 
use Coinbase\Wallet\Configuration; 

파일 상단의 문제가 해결됩니다. 그 후에 http://php.net/manual/en/language.namespaces.basics.phphttp://php.net/manual/en/language.namespaces.rationale.php을 읽으십시오.

+0

응답 해 주셔서 감사합니다. 그것은 불행히도 그것을하지 않았다. 해당 링크를 확인하려고합니다. – Shlomo7

관련 문제