🔌 PHP Youthweb API is an object-oriented wrapper for PHP of the Youthweb API.
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs
src
tests
.gitattributes
.gitignore
.php_cs.dist
.travis.yml
CHANGELOG.md
LICENSE
README.md
composer.json
phpunit.xml

README.md

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.

Unterstütze API Version: 0.12

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([
    '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

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