PHP code example of twigger / unioncloud

1. Go to this page and download the library: Download twigger/unioncloud 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/ */

    

twigger / unioncloud example snippets


use \Twigger\UnionCloud\API\UnionCloud as UnionCloudWrapper

Twigger\UnionCloud\API\UnionCloudServiceProvider::class

$unionCloud = resolve('Twigger\UnionCloud\API\UnionCloud');

$unionCloud = new UnionCloudWrapper($auth);

$auth = [
	'email'=>'[email protected]',
	'password'=>'top_secret',
	'appID'=>'MyAppID',
	'appPassword'=>'myPass'
];

$unionCloud->setBaseURL('union.unioncloud.org') ;
$unionCloud->debug();
 
users()
userGroupMemberships()

setMode($mode) // Takes basic, standard or full. Defaults to full
paginate()
setPage($page)

$user = $unionCloud->users()->search(['forename'=>'Toby'])->get()->first();

$user = $unionCloud->users()->setMode('basic')->search(['forename'=>'Toby'])->get()->first();

if($unionCloud->users()->setMode('basic')->getByUID('1234567')->getStatusCode() === 200) {
	// Request was successful
}

$user->forename
$user->dob
...

$casts = [
	'userGroupMemberships' => UserGroupMembershipResource::class
];

$event = [
	'user_uid' => 22222,
	'user_forename' => 'Toby',
	'event_id' => 3848,
	`event_name` => `Event the user 22222 set up`
];

	$event = [
		'setup_user' => UserResource[
			'uid' => 22222,
			'forename' => 'Toby'
		].
		'event_id' => 3848,
		'event_name' => 'Event the user 22222 set up'
	];

$customCasts = [
	'setup_user|'.UserResource::class => [
		'user_uid' => 'uid',
		'user_forename' => 'forename'
	],
	...
];

$users = $unionCloud->users()->paginate()->search(['forename', 'Toby'])

$users->getResponse(); // Get the UserResponse class for the first page
$users->getAllPages(); // Return a collection containing all users. This will iterate through pages until the final page is reached, so may take a while (although syncronous requests are coming!)
$users->next(); // Return the RequestClass containing the response to the next page.
$users->previous(); // Return the RequestClass containing the response to the previous page.
bash
php artisan vendor:publish --provider="Twigger\UnionCloud\API"
config/app.php