create account

Announcement new php client [php-graphene-node-client v2.2.2] by php-node-client

View this thread on: hive.blogpeakd.comecency.com
· @php-node-client · (edited)
$60.31
Announcement new php client [php-graphene-node-client v2.2.2]
# php-graphene-node-client
PHP client for connection to STEEM/GOLOS node


## Install Via Composer
```
composer require t3ran13/php-graphene-node-client
```

## Basic Usage
```php
<?php

use GrapheneNodeClient\Commands\CommandQueryData;
use GrapheneNodeClient\Commands\DataBase\GetDiscussionsByCreatedCommand;
use GrapheneNodeClient\Connectors\WebSocket\GolosWSConnector;
use GrapheneNodeClient\Connectors\WebSocket\SteemitWSConnector;


//Set params for query
$commandQuery = new CommandQueryData();
$data = [
    [
        'limit'       => $limit,
        'select_tags' => ['golos'], // for GOLOS
        'tag'         => 'steemit', // for STEEMIT     
    ]
];
$commandQuery->setParams($data);

//OR 
$commandQuery = new CommandQueryData();
$commandQuery->setParamByKey('0:limit', $limit);
$commandQuery->setParamByKey('0:select_tags', [$tag]);
$commandQuery->setParamByKey('0:tag', $tag);

$command = new GetDiscussionsByCreatedCommand(new GolosWSConnector());
$golosPosts = $command->execute(
    $commandQuery
);
// will return
// [
//      "id" => 1,
//      "result" => [
//            [
//                "id": 466628,
//                "author": "piranya",
//                "permlink": "devyatyi-krug",
//                ...
//            ],
//            ...
//      ]
// ]
  
$command = new GetDiscussionsByCreatedCommand(new SteemitWSConnector());
$steemitPosts = $command->execute(
    $commandQuery,
    'result',
    SteemitWSConnector::ANSWER_FORMAT_ARRAY // or SteemitWSConnector::ANSWER_FORMAT_OBJECT
);
// will return
// [
//      [
//          "id": 466628,
//          "author": "piranya",
//          "permlink": "devyatyi-krug",
//          ...
//      ],
//      ...
// ]


```
  
   

## Implemented Commands List

namespace: 
- GrapheneNodeClient\Commands\Broadcast;
- GrapheneNodeClient\Commands\DataBase;
- GrapheneNodeClient\Commands\Follow;
- GrapheneNodeClient\Commands\Login;

### database_api
- GetDynamicGlobalPropertiesCommand
- GetBlockCommand
- GetBlockHeaderCommand
- GetWitnessesByVoteCommand
- GetActiveWitnessesCommand
- GetAccountCommand
- GetAccountCountCommand
- GetAccountHistoryCommand
- GetAccountVotesCommand
- GetContentCommand
- GetDiscussionsByAuthorBeforeDateCommand
- GetDiscussionsByBlogCommand
- GetDiscussionsByCreatedCommand
- GetDiscussionsByFeedCommand
- GetDiscussionsByTrendingCommand
- GetTrendingCategoriesCommand
  
### login_api
- GetApiByNameCommand
- GetVersionCommand
- LoginCommand
   
  
### follow_api
- GetFollowersCommand
   
  
### broadcast_api
- BroadcastTransactionCommand
- BroadcastTransactionSynchronousCommand
   

## Implemented Connectors List

namespace: GrapheneNodeClient\Connectors\WebSocket;

- GolosWSConnector (wss://ws.golos.io)
- SteemitWSConnector (wss://ws.steemit.com)

switch between connectors 
```php
<?php

use GrapheneNodeClient\Commands\CommandQueryData;
use GrapheneNodeClient\Commands\DataBase\GetContentCommand;
use GrapheneNodeClient\Connectors\InitConnector;

$command = new GetContentCommand(InitConnector::getConnector(InitConnector::PLATFORM_STEEMIT));

$commandQuery = new CommandQueryData();
$commandQuery->setParamByKey('0', 'author');
$commandQuery->setParamByKey('1', 'permlink');

//OR
$commandQuery = new CommandQueryData();
$commandQuery->setParams(
    [
        0 => "author",
        1 => "permlink"
    ]
);

$content = $command->execute(
    $commandQuery
);
// will return
// [
//      "id" => 1,
//      "result" => [
//            ...
//      ]
// ]


```

   

## Creating Own Connector
```php
<?php

namespace My\App\Connectors;

use GrapheneNodeClient\Connectors\ConnectorInterface;

class MyConnector implements ConnectorInterface 
{
    /**
    * platform name for witch connector is. steemit or golos.
    */
    public function getPlatform() {
     // TODO: Implement getPlatform() method.
    }
    
    /**
    * @param string $apiName calling api name - follow_api, database_api and ect.
    * @param array  $data    options and data for request
    * @param string $answerFormat
    *
    * @return array|object return answer data
    */
    public function doRequest($apiName, array $data, $answerFormat = self::ANSWER_FORMAT_ARRAY) {
     // TODO: Implement doRequest() method.
    }

}


```
  
   

## Creating Own Command
```php
<?php

namespace My\App\Commands;

use GrapheneNodeClient\Commands\DataBase\CommandAbstract;
use GrapheneNodeClient\Connectors\ConnectorInterface;

class MyCommand extends CommandAbstract 
{
    protected $method            = 'method_name';
    //protected $apiName         = 'login_api'; in CommandAbstract have to be set correct $apiName
    
    //If different for platforms
    protected $queryDataMap = [
        ConnectorInterface::PLATFORM_GOLOS   => [
            //on the left is array keys and on the right is validators
            //validators for ani list element have to be have '*'  
            '*:limit'            => ['integer'], //the discussions return amount top limit
            '*:select_tags:*'    => ['nullOrString'], //list of tags to include, posts without these tags are filtered
            '*:select_authors:*' => ['nullOrString'], //list of authors to select
            '*:truncate_body'    => ['nullOrInteger'], //the amount of bytes of the post body to return, 0 for all
            '*:start_author'     => ['nullOrString'], //the author of discussion to start searching from
            '*:start_permlink'   => ['nullOrString'], //the permlink of discussion to start searching from
            '*:parent_author'    => ['nullOrString'], //the author of parent discussion
            '*:parent_permlink'  => ['nullOrString'] //the permlink of parent discussion
        ],
        ConnectorInterface::PLATFORM_STEEMIT => [
            //for list params
            '*:tag'            => ['nullOrString'], //'author',
            '*:limit'          => ['integer'], //'limit'
            '*:start_author'   => ['nullOrString'], //'start_author' for pagination,
            '*:start_permlink' => ['nullOrString'] //'start_permlink' for pagination,
        ]
    ];
    
    
    //If the same for platforms
    //protected $queryDataMap = [
    // route example: 'key:123:array' => $_SESSION['key'][123]['array']
    //    'some_array_key:some_other_key' => ['integer'],   // available validators are 'required', 'array', 'string',
                                                            // 'integer', 'nullOrArray', 'nullOrString', 'nullOrInteger'.
    //];
}


```  
   

# Tools
## Transliterator


```php
<?php

use GrapheneNodeClient\Tools\Transliterator;


//Encode tags
$tag = Transliterator::encode('пол', Transliterator::LANG_RU); // return 'pol';


//Decode tags
$tag = Transliterator::encode('ru--pol', Transliterator::LANG_RU); // return 'пол';

```


## Reputation viewer


```php
<?php

use GrapheneNodeClient\Tools\Reputation;

$rep = Reputation::calculate($account['reputation']);

```

	
-------
	
[Github](https://github.com/t3ran13/php-graphene-node-client) or [packagist](https://packagist.org/packages/t3ran13/php-graphene-node-client) with MIT license. Author @t3ran13.  Active helper @semaspring

It is better with each commit

@transisto add it to steemtools.com please
👍  , , , , , , , ,
properties (23)
authorphp-node-client
permlinkannouncement-new-php-client-php-graphene-node-client-v2-2-2
categoryopensource
json_metadata{"tags":["opensource","steemit","api","steemtools","php"],"users":["t3ran13","semaspring","transisto"],"links":["https://github.com/t3ran13/php-graphene-node-client","https://packagist.org/packages/t3ran13/php-graphene-node-client"],"app":"steemit/0.1","format":"markdown"}
created2017-10-19 09:46:48
last_update2017-10-19 10:04:24
depth0
children6
last_payout2017-10-26 09:46:48
cashout_time1969-12-31 23:59:59
total_payout_value46.349 HBD
curator_payout_value13.965 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length7,199
author_reputation574,145,594,155
root_title"Announcement new php client [php-graphene-node-client v2.2.2]"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id18,041,667
net_rshares26,250,678,946,190
author_curate_reward""
vote details (9)
@chairil05 ·
Thanks informasinya...
properties (22)
authorchairil05
permlinkre-php-node-client-announcement-new-php-client-php-graphene-node-client-v2-2-2-20171019t101957390z
categoryopensource
json_metadata{"tags":["opensource"],"app":"steemit/0.1"}
created2017-10-19 10:20:06
last_update2017-10-19 10:20:06
depth1
children0
last_payout2017-10-26 10:20:06
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length22
author_reputation3,557,751,028
root_title"Announcement new php client [php-graphene-node-client v2.2.2]"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id18,043,428
net_rshares0
@cheetah ·
Hi! I am a robot. I just upvoted you! I found similar content that readers might be interested in:
https://packagist.org/packages/t3ran13/php-graphene-node-client
properties (22)
authorcheetah
permlinkcheetah-re-php-node-clientannouncement-new-php-client-php-graphene-node-client-v2-2-2
categoryopensource
json_metadata""
created2017-10-19 09:47:15
last_update2017-10-19 09:47:15
depth1
children1
last_payout2017-10-26 09:47:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length162
author_reputation942,693,160,055,713
root_title"Announcement new php client [php-graphene-node-client v2.2.2]"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id18,041,696
net_rshares0
@t3ran13 ·
you are too young to understand
properties (22)
authort3ran13
permlinkre-cheetah-cheetah-re-php-node-clientannouncement-new-php-client-php-graphene-node-client-v2-2-2-20171019t095529141z
categoryopensource
json_metadata{"tags":["opensource"],"app":"steemit/0.1"}
created2017-10-19 09:55:30
last_update2017-10-19 09:55:30
depth2
children0
last_payout2017-10-26 09:55:30
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length31
author_reputation50,037,290,585,145
root_title"Announcement new php client [php-graphene-node-client v2.2.2]"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id18,042,120
net_rshares0
@steemitboard ·
Congratulations @php-node-client! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

[![](https://steemitimages.com/70x80/http://steemitboard.com/notifications/firstpost.png)](http://steemitboard.com/@php-node-client) You published your First Post
[![](https://steemitimages.com/70x80/http://steemitboard.com/notifications/firstvoted.png)](http://steemitboard.com/@php-node-client) You got a First Vote

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click [here](https://steemit.com/@steemitboard)

If you no longer want to receive notifications, reply to this comment with the word `STOP`

> By upvoting this notification, you can help all Steemit users. Learn how [here](https://steemit.com/steemitboard/@steemitboard/http-i-cubeupload-com-7ciqeo-png)!
properties (22)
authorsteemitboard
permlinksteemitboard-notify-php-node-client-20171019t115938000z
categoryopensource
json_metadata{"image":["https://steemitboard.com/img/notifications.png"]}
created2017-10-19 11:59:36
last_update2017-10-19 11:59:36
depth1
children0
last_payout2017-10-26 11:59:36
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length857
author_reputation38,975,615,169,260
root_title"Announcement new php client [php-graphene-node-client v2.2.2]"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id18,049,590
net_rshares0
@transisto ·
Could you suggest me specifically what to write on steemtools listing?

DM me on Steemit.chat
properties (22)
authortransisto
permlinkre-php-node-client-announcement-new-php-client-php-graphene-node-client-v2-2-2-20171022t180330386z
categoryopensource
json_metadata{"tags":["opensource"],"app":"steemit/0.1"}
created2017-10-22 18:03:33
last_update2017-10-22 18:03:33
depth1
children1
last_payout2017-10-29 18:03:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length93
author_reputation330,357,940,720,833
root_title"Announcement new php client [php-graphene-node-client v2.2.2]"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id18,319,064
net_rshares0
@php-node-client ·
it is the same to steemphp
properties (22)
authorphp-node-client
permlinkre-transisto-re-php-node-client-announcement-new-php-client-php-graphene-node-client-v2-2-2-20171023t172803709z
categoryopensource
json_metadata{"tags":["opensource"],"app":"steemit/0.1"}
created2017-10-23 17:28:15
last_update2017-10-23 17:28:15
depth2
children0
last_payout2017-10-30 17:28:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length26
author_reputation574,145,594,155
root_title"Announcement new php client [php-graphene-node-client v2.2.2]"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id18,387,508
net_rshares0