Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

PHP Youthweb API

Latest Version Software License GPLv3 Build Status Coverage Status Gitter

PHP Youthweb API ist ein objektorientierter Wrapper in PHP 5.6+ fΓΌr die Youthweb API.

Installation

Composer:

$ composer require youthweb/php-youthweb-api

Dokumentation / Anwendung

<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);

// Config
$client_id = 'CB91ZullPa4ync4l';
$client_secret = 'YC7CXuDXX9pF5SeTKs9enkoPjbV01QIs';
$redirect_url = 'http://localhost/php-youthweb-api/login-button.php';
$scope = ['user:read']; // See http://developer.youthweb.net/api_general_scopes.html

require 'vendor/autoload.php';

$client = new Youthweb\Api\Client([
    'api_version'   => '0.18',
    'client_id'     => $client_id,
    'client_secret' => $client_secret,
    'redirect_url'  => $redirect_url,
    'scope'         => $scope,
]);

echo '<h1>Mit Youthweb einloggen</h1>';
echo '<form method="get" action="'.$redirect_url.'">
<input name="go" value="Login" type="submit" />
</form>';

if ( isset($_GET['go']) )
{
    if ( ! $client->isAuthorized() )
    {
        header('Location: '.$client->getAuthorizationUrl());
        exit;
    }

    $me = $client->getResource('users')->showMe();

    printf('<p>Hallo %s %s!</p>', $me->get('data.attributes.first_name'), $me->get('data.attributes.last_name'));
    printf('<p>Deine Email-Adresse: %s', $me->get('data.attributes.email'));
}
elseif ( isset($_GET['code']) )
{
    $client->authorize('authorization_code', [
        'code' => $_GET['code'],
        'state' => $_GET['state'],
    ]);

    header('Location: '.$redirect_url.'?go=Login');
    exit;
}

Weitere Informationen zur Anwendung gibt es in der Dokumentation.

Tests

phpunit

Changelog

Der Changelog ist hier zu finden und folgt den Empfehlungen von keepachangelog.com.

Todo

  • Erstellen von Posts auf Endpoint /{object}/{object_id}/posts
  • Zugriff auf /events Resourcen
  • Zugriff auf /friends Resourcen
  • Zugriff auf /{object}/{id}/friends Resourcen
  • Request Error Handling

About

πŸ”Œ PHP Youthweb API is an object-oriented wrapper for PHP of the Youthweb API.

Resources

License

Packages

No packages published

Languages