コード例 #1
0
ファイル: sync.php プロジェクト: joomlacn/DogecoinTipping
 /**
  * add a wallet address to a user
  * 
  * @access public
  * @param int $user_id
  * @param string $label
  */
 public function addAddress($user_id, $label = '')
 {
     $params = JComponentHelper::getParams('com_dogecointipping');
     $apiKey = $params->get('api_key');
     $pin = $params->get('secret_pin');
     require_once JPATH_ADMINISTRATOR . '/components/com_dogecointipping/libs/block_io.php';
     $block_io = new BlockIO($apiKey, $pin, 2);
     try {
         if (empty($label)) {
             $getNewAddressInfo = $block_io->get_new_address();
         } else {
             $getNewAddressInfo = $block_io->get_new_address(array('label' => $label));
         }
         $newAddress = $getNewAddressInfo->data->address;
         $newLabel = $getNewAddressInfo->data->label;
         $db = JFactory::getDBO();
         $record = new stdClass();
         $record->user_id = $user_id;
         $date = JFactory::getDate();
         $record->created = $date->toSql();
         $record->label = $newLabel;
         $record->address = $newAddress;
         $db->insertObject('#__dogecointipping_address', $record);
     } catch (Exception $e) {
         $this->setError($e->getMessage());
         return false;
     }
 }
コード例 #2
0
ファイル: address.php プロジェクト: joomlacn/DogecoinTipping
 public function addAddress($label)
 {
     $params = JComponentHelper::getParams('com_dogecointipping');
     $apiKey = $params->get('api_key');
     $pin = $params->get('secret_pin');
     require_once JPATH_ADMINISTRATOR . '/components/com_dogecointipping/libs/block_io.php';
     $block_io = new BlockIO($apiKey, $pin, 2);
     try {
         if (empty($label)) {
             $getNewAddressInfo = $block_io->get_new_address();
         } else {
             $getNewAddressInfo = $block_io->get_new_address(array('label' => $label));
         }
         $newAddress = $getNewAddressInfo->data->address;
         $newLabel = $getNewAddressInfo->data->label;
         return array('label' => $newLabel, 'address' => $newAddress);
     } catch (Exception $e) {
         $this->setError($e->getMessage());
         return false;
     }
 }