jsamos / lafitbit
Laravel 4 Wrapper for fitbitphp package
dev-master
2013-12-16 22:25 UTC
Requires
- php: >=5.3.0
- illuminate/support: 4.1.x
- popthestack/fitbit: dev-master
This package is not auto-updated.
Last update: 2024-12-17 02:43:47 UTC
README
Laravel 4 Wrapper for fitbitphp package
Setup
composer.json
{
"require": {
"slender/auth": "dev-master"
}
}
add service provider and facade to app/config/app.php
'providers' => array(
...
'Jsamos\Lafitbit\LafitbitServiceProvider',
...
);
...
'aliases' => array(
...
'Fitbit' => 'Jsamos\Lafitbit\Facades\Fitbit',
...
);
Usage
Each of the ApiGateways in the parent project are available through static methods
e.g. $factory->getUserGateway becomes Fitbit::user()
Example
class FitbitController extends Controller {
public function oauth()
{
$auth = Fitbit::authentication();
$auth->initiateLogin();
}
public function authenticate()
{
$auth = Fitbit::authentication();
$oauth_token = Input::get('oauth_token');
$oauth_verifier = Input::get('oauth_verifier');
$auth->authenticateUser($oauth_token, $oauth_verifier);
if ($auth->isAuthorized()) {
$profile = Fitbit::user()->getProfile();
var_dump($profile);
} else {
echo 'Not connected.';
}
}
}