1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Coinbase Experts?

Discussion in 'PHP' started by Jeremy Benson, Nov 18, 2015.

  1. #1
    Hello,

    I'm messing with the Coinbase api, but documentation is really sparse. I'm not using oauth, but rather api keys. I've got the library installed, and guzzler installed, because it's a dependency, but still have trouble.

    I'm getting error: Class 'Coinbase\Wallet\Resource\Resource' not found in Account.php line 11. I could fix the error if I could add a namespace path, but can't find it in the class

    I'm unsure how to return an address to send the money to.

    
      // guzzle includes
             require('../../lib/guzzle/src/RedirectMiddleware.php');
             require('../../lib/guzzle/src/Middleware.php');
             require('../../lib/guzzle/src/Handler/StreamHandler.php');
             require('../../lib/guzzle/src/Handler/CurlHandler.php');
             require('../../lib/guzzle/src/Handler/CurlFactoryInterface.php');
             require('../../lib/guzzle/src/Handler/CurlFactory.php');
             require('../../lib/guzzle/src/Handler/CurlMultiHandler.php');
             require('../../lib/guzzle/src/Handler/Proxy.php');
             require('../../lib/guzzle/src/functions.php');
             require('../../lib/guzzle/src/HandlerStack.php');
             require('../../lib/guzzle/src/ClientInterface.php');
             require('../../lib/guzzle/src/Client.php');
          
             require('../../data/coinbasedata.php');
             // Request the funds here
               // coinbase includes
             require('../../lib/src/Resource/Account.php');
             require('../../lib/src/Enum/ResourceType.php');
             require('../../lib/src/Enum/TransactionType.php');
             require('../../lib/src/Enum/CurrencyCode.php');
             require('../../lib/coinbase/src/ActiveRecord/BaseActiveRecord.php');
             require('../../lib/coinbase/src/ActiveRecord/TransactionActiveRecord.php');
             require('../../lib/coinbase/src/Resource/AccountResource.php');
             require('../../lib/coinbase/src/Resource/Resource.php');
             require('../../lib/coinbase/src/Resource/Transaction.php');
             require('../../lib/coinbase/src/Mapper.php');
             require('../../lib/coinbase/src/Authentication/Authentication.php');
             require('../../lib/coinbase/src/Authentication/ApiKeyAuthentication.php');
             require('../../lib/coinbase/src/HttpClient.php');
             require('../../lib/coinbase/src/Client.php');
             require('../../lib/coinbase/src/Configuration.php');
             require('../../lib/src/Value/Money.php');
          
               // recieve send
             $configuration = Coinbase\Wallet\Configuration::apiKey($coinbaseAPIKey, $coinbaseSecretKey);
             $configuration->setApiUrl(Coinbase\Wallet\Configuration::DEFAULT_API_URL);
             $client = Coinbase\Wallet\Client::create($configuration);
      
             $transaction = Coinbase\Wallet\Resource\Transaction::request([
                             'amount'  => new Coinbase\Wallet\Value\Money($_POST['amount'],  Coinbase\Wallet\Enum\CurrencyCode::BTC),
                             'description' => 'Test'
                           ]);
    
             $account = $client->getPrimaryAccount();
             $client->createAccountTransaction($account, $transaction);
        
             var_dump($client);
    
    PHP:
    here's the account.php

    
    <?php
    
    namespace Coinbase\Wallet\Resource;
    
    use Coinbase\Wallet\ActiveRecord\AccountActiveRecord;
    use Coinbase\Wallet\Enum\AccountType;
    use Coinbase\Wallet\Enum\ResourceType;
    use Coinbase\Wallet\Value\Money;
    
    class Account extends Resource
    {
      use AccountActiveRecord;
    
      /** @var string */
      private $name;
    
      /** @var Boolean */
      private $primary;
    
      /**
      * @var string
      * @see AccountType
      */
      private $type;
    
      /** @var string */
      private $currency;
    
      /** @var Money */
      private $balance;
    
      /** @var Money */
      private $nativeBalance;
    
      /** @var \DateTime */
      private $createdAt;
    
      /** @var \DateTime */
      private $updatedAt;
    
      /**
      * Creates an account reference.
      *
      * @param string $accountId The account id
      *
      * @return Account An account reference
      */
      public static function reference($accountId)
      {
      return new static('/v2/accounts/'.$accountId);
      }
    
      public function __construct($resourcePath = null)
      {
      parent::__construct(ResourceType::ACCOUNT, $resourcePath);
      }
    
      public function getName()
      {
      return $this->name;
      }
    
      public function setName($name)
      {
      $this->name = $name;
      }
    
      public function isPrimary()
      {
      return $this->primary;
      }
    
      public function getType()
      {
      return $this->type;
      }
    
      public function getCurrency()
      {
      return $this->currency;
      }
    
      public function getBalance()
      {
      return $this->balance;
      }
    
      public function getNativeBalance()
      {
      return $this->nativeBalance;
      }
    
      public function getCreatedAt()
      {
      return $this->createdAt;
      }
    
      public function getUpdatedAt()
      {
      return $this->updatedAt;
      }
    }
    
    
    PHP:
     
    Last edited: Nov 18, 2015
    Jeremy Benson, Nov 18, 2015 IP
  2. Jeremy Benson

    Jeremy Benson Well-Known Member

    Messages:
    364
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    123
    #2
    I guess there were a lot of dependencies missing. Guzzle, psr7, Guzzle Promises. I've got them all in and then came to a new error. Does this ring a bell with anyone here?

    ( ! ) InvalidArgumentException: SSL CA bundle not found: C:\wamp\www\lib\coinbase\src/../etc/ca-coinbase.crt in C:\wamp\www\lib\guzzle\src\Handler\CurlFactory.php on line 328

    This is the relating function in curlfactory:

    
    
    private function applyHandlerOptions(EasyHandle $easy, array &$conf)
      {
    
           $options = $easy->options;
           if (isset($options['verify'])) {
           
               if ($options['verify'] === false) {
                   unset($conf[CURLOPT_CAINFO]);
                   $conf[CURLOPT_SSL_VERIFYHOST] = 0;
                   $conf[CURLOPT_SSL_VERIFYPEER] = false;
               } else {
                   $conf[CURLOPT_SSL_VERIFYHOST] = 2;
                   $conf[CURLOPT_SSL_VERIFYPEER] = true;
                if (is_string($options['verify'])) {
                    $conf[CURLOPT_CAINFO] = $options['verify'];
                        if (!file_exists($options['verify'])) {
                           throw new \InvalidArgumentException(
                          "SSL CA bundle not found: {$options['verify']}"
                       );
              }
          }
        }
      }
    
    PHP:
     
    Last edited: Nov 18, 2015
    Jeremy Benson, Nov 18, 2015 IP
  3. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #3
    Not an expert on it, don't even know what it is (though if it's related to e-currency my attitude on it ranging from outright scam to pipe-dream stoner naivete might have something to do with that) -- but I would automatically reject anything that had that many "require" statements... as a matter of principle alone. It just SCREAMS "herpaderp I'm slapping other people's code together and blindly hoping it works" -- Looks like it needs a small army of dependencies that would send me looking for some other script to handle it.

    That said, it looks like it wants you to generate a SSL certificate to be placed in that file location, and it's not there. That's typically command line stuff using openssl. I'm not familiar with this library, but have you tried seeing if they have installation docs that mention things like that? Of course since you're on WAMP I've NO clue how to generate that certificate file, I've never made a SSL cert on windows, and I'm not sure you could even test such code properly since if it's trying to find a SSL cert, it's gonna probably try to use something like CURL to https and respond to https... and WAMP/XAMPP and other windows installations of Apache are notorious for falling flat on their face for that.

    I mean if you were on a *nix flavor that would simply be navigate to that directory and type:

    openssl req -new > ca-coinbase.crt

    Except they may want your "coinbase certificate" or "wallet certificate" if it's some kind of bitcoin type asshattery.

    Though honestly, checking if it exists and not if it's valid against whatever source is being handled seems a bit wonky, but I'm hoping they just do that elsewhere later in the code, hence the "throw".
     
    deathshadow, Nov 18, 2015 IP
  4. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #4
    HeyZeus H mammary plowing Christmas; Just found the website for it tried to go into the docs or tutorials -- that's the most useless endless link-looping broken documentation I've ever seen. Good luck getting THAT to work. I can see why you are having problems. I get four pages deep, find a link to "Learn how to use our API" that took me back to the first blasted page I was on.

    I've dealt with overseas phone support that gave me less of a run-around. Clearly writen by a marketing executive and some SEO hoodoo-voodoo scam artist, and not anyone who actually understands that when documenting an API it helps to just document it, not keyword stuff the crap out of it with market-speak.

    This page ALONE:
    https://developers.coinbase.com/docs/wallet/tutorials/ecommerce-tutorial

    ... and how I got to it, would make me punch a marketing executive in the face.
     
    deathshadow, Nov 18, 2015 IP
  5. Jeremy Benson

    Jeremy Benson Well-Known Member

    Messages:
    364
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    123
    #5
    Hey,

    Sorry. I guess they have a composer file. I never knew about composer until a couple days ago. Got it installed, but not sure how far I'll go with that project. They sent me and e-mail with a text dump of the needed code too... I don't think the site is a scam, just under known. They've got backing form major companies, and I believe United Way uses them to accept donations :)

    How come you hate e-currency? Isn't it the same as money, as long as people give it value :p
     
    Jeremy Benson, Nov 24, 2015 IP
  6. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #6
    It has a lot of the 'tells' of overzealous marketing, and that always makes me leery -- like putting soft sell on every blasted page of the tutorial. BIG TIP, if someone is reading the tutorial you've already sold them. It reeks of trying to dupe some suit who knows nothing about programming into THINKING it's easy, leaving the poor sod actually trying to implementing screaming at the walls.

    Having worked for non-profit organizations in the development (aka fundraising) side of things, that's NOT exactly a selling point. To put it frankly such places will do anything and everything to take anything resembling currency, often beyond the point of reason... quite often to the point where it costs more in manpower and startup cost to take or recruit the donation than was recovered.

    Saw this first-hand back in the '90's, company I worked for always did (fake, daisy wheel printed) hand typed letters in plain envelopes that were signed by an array of volunteers, that consistently cleared 90% profit. The "last minute" hurricane damage mailing for example cost around $10K to produce and cleared half a million.... then this new "development" expert came in and blew a quarter of a million on full colour glossy mass mailing to ten times as many people, and that campaign only cleared $300k but was hailed as a "massive success". But it took in more money! -- even the finance people were praising it and I'm like "yeah, but it cleared a fifth what the old mailings did!!!" -- NOBODY got it. :(

    I think that's where the seed for my distrust of glossy, flashy, artsy stuff was planted.

    Nothing I use accepts it (at least not from here even from places people claim do... ONLINE?!?), I find the entire notion of it absurd, and it's more of a house of cards than alleged real money or leaving money in a bank; laughably I have little if any trust for that either particularly with the interest rates so low you're better off with a CD or money market account.

    See "the Donald", who'd have made more money putting all the cash daddy gave him into CD's than he would have being "Slum lord of the rich".

    Hence why daddy had to bail him out twice. It's easy to be a billionaire when you start out at half a billion and pops lends you millions under the table.
     
    deathshadow, Nov 26, 2015 IP
  7. Jeremy Benson

    Jeremy Benson Well-Known Member

    Messages:
    364
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    123
    #7
    Hm, interesting spin. I still have some faith in Bitcoin though. :p The fact that I sought and bought $10 worth myself on-line means it can be marketed. I wouldn't want to tie millions into it though.. better off selling it as quick as possible.
     
    Jeremy Benson, Nov 26, 2015 IP
  8. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #8
    ... which is something else it reminds me of; pump and dump.

    But then a decade and a half ago I worked for Enron, so I'm a bit paranoid on that count.
     
    deathshadow, Nov 26, 2015 IP