# 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
author | php-node-client |
---|---|
permlink | announcement-new-php-client-php-graphene-node-client-v2-2-2 |
category | opensource |
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"} |
created | 2017-10-19 09:46:48 |
last_update | 2017-10-19 10:04:24 |
depth | 0 |
children | 6 |
last_payout | 2017-10-26 09:46:48 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 46.349 HBD |
curator_payout_value | 13.965 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 7,199 |
author_reputation | 574,145,594,155 |
root_title | "Announcement new php client [php-graphene-node-client v2.2.2]" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 18,041,667 |
net_rshares | 26,250,678,946,190 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
transisto | 0 | 11,350,784,858,568 | 100% | ||
cheetah | 0 | 794,057,217 | 0.5% | ||
celebr1ty | 0 | 278,224,761,517 | 100% | ||
t3ran13 | 0 | 12,320,736,288 | 100% | ||
xroni | 0 | 9,999,130,413 | 100% | ||
steemitboard | 0 | 383,169,275 | 1% | ||
newsflash | 0 | 14,597,366,910,274 | 100% | ||
semasping | 0 | 561,670,200 | 100% | ||
asmaasema | 0 | 243,652,438 | 100% |
Thanks informasinya...
author | chairil05 |
---|---|
permlink | re-php-node-client-announcement-new-php-client-php-graphene-node-client-v2-2-2-20171019t101957390z |
category | opensource |
json_metadata | {"tags":["opensource"],"app":"steemit/0.1"} |
created | 2017-10-19 10:20:06 |
last_update | 2017-10-19 10:20:06 |
depth | 1 |
children | 0 |
last_payout | 2017-10-26 10:20:06 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 22 |
author_reputation | 3,557,751,028 |
root_title | "Announcement new php client [php-graphene-node-client v2.2.2]" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 18,043,428 |
net_rshares | 0 |
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
author | cheetah |
---|---|
permlink | cheetah-re-php-node-clientannouncement-new-php-client-php-graphene-node-client-v2-2-2 |
category | opensource |
json_metadata | "" |
created | 2017-10-19 09:47:15 |
last_update | 2017-10-19 09:47:15 |
depth | 1 |
children | 1 |
last_payout | 2017-10-26 09:47:15 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 162 |
author_reputation | 942,693,160,055,713 |
root_title | "Announcement new php client [php-graphene-node-client v2.2.2]" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 18,041,696 |
net_rshares | 0 |
you are too young to understand
author | t3ran13 |
---|---|
permlink | re-cheetah-cheetah-re-php-node-clientannouncement-new-php-client-php-graphene-node-client-v2-2-2-20171019t095529141z |
category | opensource |
json_metadata | {"tags":["opensource"],"app":"steemit/0.1"} |
created | 2017-10-19 09:55:30 |
last_update | 2017-10-19 09:55:30 |
depth | 2 |
children | 0 |
last_payout | 2017-10-26 09:55:30 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 31 |
author_reputation | 50,037,290,585,145 |
root_title | "Announcement new php client [php-graphene-node-client v2.2.2]" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 18,042,120 |
net_rshares | 0 |
Congratulations @php-node-client! You have completed some achievement on Steemit and have been rewarded with new badge(s) : [](http://steemitboard.com/@php-node-client) You published your First Post [](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)!
author | steemitboard |
---|---|
permlink | steemitboard-notify-php-node-client-20171019t115938000z |
category | opensource |
json_metadata | {"image":["https://steemitboard.com/img/notifications.png"]} |
created | 2017-10-19 11:59:36 |
last_update | 2017-10-19 11:59:36 |
depth | 1 |
children | 0 |
last_payout | 2017-10-26 11:59:36 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 857 |
author_reputation | 38,975,615,169,260 |
root_title | "Announcement new php client [php-graphene-node-client v2.2.2]" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 18,049,590 |
net_rshares | 0 |
Could you suggest me specifically what to write on steemtools listing? DM me on Steemit.chat
author | transisto |
---|---|
permlink | re-php-node-client-announcement-new-php-client-php-graphene-node-client-v2-2-2-20171022t180330386z |
category | opensource |
json_metadata | {"tags":["opensource"],"app":"steemit/0.1"} |
created | 2017-10-22 18:03:33 |
last_update | 2017-10-22 18:03:33 |
depth | 1 |
children | 1 |
last_payout | 2017-10-29 18:03:33 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 93 |
author_reputation | 330,357,940,720,833 |
root_title | "Announcement new php client [php-graphene-node-client v2.2.2]" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 18,319,064 |
net_rshares | 0 |
it is the same to steemphp
author | php-node-client |
---|---|
permlink | re-transisto-re-php-node-client-announcement-new-php-client-php-graphene-node-client-v2-2-2-20171023t172803709z |
category | opensource |
json_metadata | {"tags":["opensource"],"app":"steemit/0.1"} |
created | 2017-10-23 17:28:15 |
last_update | 2017-10-23 17:28:15 |
depth | 2 |
children | 0 |
last_payout | 2017-10-30 17:28:15 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 26 |
author_reputation | 574,145,594,155 |
root_title | "Announcement new php client [php-graphene-node-client v2.2.2]" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 18,387,508 |
net_rshares | 0 |