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->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()->vote(
new \XzSoftware\WykopSDK\Links\Request\Related\VoteUp(1234, 12345)
);
$sdk->links()->related()->vote(
new \XzSoftware\WykopSDK\Links\Request\Related\VoteDown(1234, 12345)
);