Download the PHP package black/yo-php without Composer
On this page you can find all versions of the php package black/yo-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package yo-php
Yo PHP
Yo PHP is a Yo client written in PHP. This library is still a work in progress.
Installation
The recomanded way to install Yo PHP is through Composer:
Protip: You should browse the black/yo-php
page to choose a stable version to use, avoid the @stable
meta
constraint.
Yotip: You want to know when yo-php is updated? Add YOPHPCLIENT \o/!
Usage
yoAll
nutshell:
The yoAll
method will send a yo to all your friends.
yo
nutshell:
The yo
method will send a yo to a dedicated username. This username MUST be in uppercase and this is your
responsibility.
subscribers_count
nutshell:
The subscribersCount
method will retrieve the number of your subscribers. This is just a GET request with a json
response.
If you want to convert the json to an array just replace $status->subscribersCount()
by
$status->subscribersCount()->json()
Send a link:
It is possible to send a link through Yo since 08/15/2014. Just add a link
key to the constructor of new Yo()
or
use $yo->addLink('url://myurl.com');
.
Send a location:
It is possible to send your location since 10/07/2014. Just add a location
key to the constructor of new Yo()
or
use this code.
Warning 1 It is not possible to receive or send link and location at the same time. When you construct a Yo with link and location, link is always overrided to null.
If you use ->add(Location|Link)
function, the class will set the other parameter to null. The code is very simple so take
your time and look at the src/spec/Yo/YoSpec.php
.
Warning 2 Yo api not using a valid format for coordinates. They use ";" instead of "," so be aware of this and don't forget to explode/convert your values (see example below).
Receive a yo:
During the registration process, Yo will ask to if you want to know when an Yo user Yo you. This pingback send you a
GET request with the Yo username
and location
query parameters.
So... You need to create a dedicated controller. For example:
As you can see, the ReceiveYoService
will dispatch an event named yo.receive
and getting his information from a
YoUser
.
I made the choice of create a true model because you maybe want to persist all your Yo friends in a database or anything you want.
A "default" subscriber is located in Yo/Event
directory. This YoSubscriber
will add a new line in your Monolog logs.
If you want to use it, use this sample code (or see the ./tests/Yo/ReceiveYoServiceTest
:
Running the tests
There is no development key for Yo so the only way to pass the tests suite is to replace the fake token and run the tests.
Contributing
See CONTRIBUTING file.
Credits
This README is heavily inspired by Hateoas library by the great @willdurand. This guy needs your PR for the sake of the REST in PHP.
Alexandre "pocky" Balmes buy me gift or hire me!
License
Yo PHP is released under the MIT License. See the bundled LICENSE file for details.
All versions of yo-php with dependencies
symfony/options-resolver Version ~2.5
symfony/event-dispatcher Version ~2.5
guzzlehttp/guzzle Version ~4
monolog/monolog Version ~1.10