PHP code example of xzsoftware / wykopsdk

1. Go to this page and download the library: Download xzsoftware/wykopsdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

xzsoftware / wykopsdk example snippets


use XzSoftware\WykopSDK\Exceptions\ApiException;
use XzSoftware\WykopSDK\Profile\Request\Profile;
use XzSoftware\WykopSDK\SDK;
use XzSoftware\WykopSDK\UserManagement\Request\Login;

$sdk = SDK::buildNewSDK('APP_KEY','APP_SECRET');
try {
    $loginResponse = $sdk->auth()->logIn(new Login('USER_NAME', 'USER_ACCOUNT_KEY'));
    $sdk->auth()->authUser('micke', $loginResponse->getUserKey());
    $sdk->profiles()->getProfile(new Profile('micke'));
} catch (ApiException $e) {
    echo $e->getMessage();
    die();
}



$sdk = XzSoftware\WykopSDK\SDK\SDK::buildNewSDK('APP_KEY','APP_SECRET');

$sdk = XzSoftware\WykopSDK\SDK\SDK::buildNewSDK('APP_KEY','APP_SECRET');
$sdk->auth()->getConnectLink('127.0.0.1/redirectUrl'); // will return url that yuser needs to follow to access your app. He will be then redirected to redirectUrl param.

// on redirect page you need to read connect data
$data = $sdk->auth()->getAuthFromConnectData(
    $_GET['connectData']
);

// now you can authenticate user with this data:
$sdk->auth()->authUser($data->getLogin(), $data->getToken())

use XzSoftware\WykopSDK\SDK;
use XzSoftware\WykopSDK\UserManagement\Request\Login;

$sdk = SDK::buildNewSDK('APP_KEY','APP_SECRET');
$loginResponse = $sdk->auth()->logIn(new Login('USER_NAME', 'USER_ACCOUNT_KEY'));
$sdk->auth()->authUser('USER_NAME', $loginResponse->getUserKey());


$sdk
    ->links()
    ->related()
    ->add(
        new \XzSoftware\WykopSDK\Links\Request\Related\Add(
            12345,
            'http://some.valid.url',
            'some title'
        )
    );

$sdk->links()->related()->vote(
        new \XzSoftware\WykopSDK\Links\Request\Related\VoteUp(1234, 12345)
    );
$sdk->links()->related()->vote(
        new \XzSoftware\WykopSDK\Links\Request\Related\VoteDown(1234, 12345)
    );

$sdk->privateMessages()->getConversation('username');

$followersRequest = new \XzSoftware\WykopSDK\Profile\Request\Followers('user');
$followersRequest->setPage(3);
$sdk->profiles()->getFollowers($followersRequest);

    $request->setUserKey('key');
    $request->setAppKey('key');
bash
# Install Composer
curl -sS https://getcomposer.org/installer | php
bash
php composer.phar 
bash
php composer.phar update