dev-master
9999999-dev https://github.com/HerveKoener/stellar-crawler-phpA Readonly API for the Stellar network
MIT
The Requires
- php >=5.3
by Herve Koener
api requests stellar
Wallogit.com
2017 © Pedro Peláez
A Readonly API for the Stellar network
This is a simple read-only PHP API for the stellar network., (*1)
This library has no dependencies., (*2)
IDEAL FOR: Quick hacking or small projects StellarCrawler provides a PHP Archive file that includes the entire library. Simply download this file and include it in your code., (*3)
<?php
// Point to where you downloaded the phar
include('./StellarCrawler.phar');
// And you're ready to go!
$publicKey = 'GXXXXXXX123456789XXX';
$isPublicNetwork = true;
$crawler = StellarCrawler::newInstance($publicKey, $isPublicNetwork);
...
IDEAL FOR: Projects that already support Composer, the sane alternative to PEAR., (*4)
Composer is starting to emerge as the true people's package manager for PHP. If you aren't already using it, you should give it a shot. Simply add quasark/stellar-crawler to require in your composer.json file like below. After doing so, you're all set to start using Httpful! The autoloader provided by composer takes care of the rest!, (*5)
{
"require": {
"quasark/stellar-crawler": "*"
}
}
First of all you need to instanciate your crawler by using the newInstance factory method:, (*6)
$publicKey = 'GXXXXXXX123456789XXX'; $isPublicNetwork = true; $crawler = StellarCrawler::newInstance($publicKey, $isPublicNetwork);
Then you can navigate through the Stellar network by using the follow() method provided by the StellarLink object:, (*7)
$crawler->getlinks()['next']->follow(); var_dump($crawler->getData()); $crawler->followPrev();
There are also helper methods that can be used to navigate easily:, (*8)
//Follow the next link $crawler->followNext(); //Follow the prev link $crawler->followPrev(); //Go back to the previous page $crawler->followBack();
When you have navigated to your favourite page, you can retrieve the data by using the getData() method:, (*9)
var_dump($crawler->getData());
The API provide another way to instanciate the StellarCrawler. The public factory method newInstanceWithServer allows to instanciate the crawler with custom horizon server:, (*10)
$publicKey = 'GXXXXXXX123456789XXX'; $horizonServer = 'https://horizon-testnet.stellar.org'; $crawler = StellarCrawler::newInstanceWithServer($publicKey, $horizonServer);
StellarCrawler API provide a historisation mechanism in order to keep track of your journey in the Stellar network. The simplest way to use the historisation mechanism is to call the followBack() method. But you can retrieve the full history by calling getHistory():, (*11)
var_dump($crawler->getHistory());
This method returns an array of StellarLink representing the navigation history., (*12)
StellarCrawler->getlinks() contains an array of array with:, (*13)
StellarCrawler->getData() contains the json representation of the data sent by the Stellar network., (*14)
var_dump($crawler->getData());
StellarCrawler->getHistory() contains an array of StellarLink representing the navigation history., (*15)
StellarCrawler->followNext() follows the 'next' link if available. If the current page doesn't contain a 'next' link, a StellarCrawlerException is thrown. This method is the same as using StellarCrawler->getlinks()['next']->follow();, (*16)
StellarCrawler->followPrev() follows the 'prev' link if available. If the current page doesn't contain a 'prev' link, a StellarCrawlerException is thrown. This method is the same as using StellarCrawler->getlinks()['prev']->follow();, (*17)
StellarCrawler->followBack() follows the 'back' link if available. If the current page doesn't contain a 'back' link, a StellarCrawlerException is thrown. This method is the same as using StellarCrawler->getlinks()['back']->follow();, (*18)
See the example for more information., (*19)
XLM donations are welcome! : GC6ZIWMTBZZ54VWX6SJH4JEHRHWSE245O2EIW26CMGAS6PM2R4J6V4PH, (*20)
GNU General Public License v3.0, (*21)
A Readonly API for the Stellar network
MIT
api requests stellar