PHP code example of michaelhull / connectwise-php-client
1. Go to this page and download the library: Download michaelhull/connectwise-php-client 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/ */
michaelhull / connectwise-php-client example snippets
'connectwise' => [
'company_id' => env('CW_COMPANY_ID'),
'integrator' => env('CW_INTEGRATOR'),
'password' => env('CW_PASSWORD'),
'url' => env('CW_URL'),
],
'providers' => [
# other providers omitted
Spinen\ConnectWise\Laravel\ServiceProvider::class,
],
'aliases' => [
# other aliases omitted
'ConnectWise' => Spinen\ConnectWise\Laravel\Facades\ConnectWise::class,
],
config/services.php
config/app.php
config/app.php
$ php artisan tinker
Psy Shell v0.8.0 (PHP 7.0.14 — cli) by Justin Hileman
>>> Auth::loginUsingId(1);
PHP warning: unlink(/Users/jimmy.puckett/git/swaginator.com/storage/framework/sessions/1aMf1yhUe6h4Ij2GRvq5UYab1IqK7GVn1qkyWPY6): No such file or directory in /Users/jimmy.puckett/git/swaginator.com/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php on line 172
=> App\User {#983
id: "1",
first_name: "Joe",
last_name: "Doe",
email: "[email protected] ",
admin: "0",
created_at: "2017-01-02 18:30:47",
updated_at: "2017-01-12 22:22:39",
logged_in_at: "2017-01-12 22:22:39",
deleted_at: null,
}
>>> $cw = app('Spinen\ConnectWise\Api\Client');
=> Spinen\ConnectWise\Api\Client {#934}
>>> $info = $cw->get('system/info');
=> Spinen\ConnectWise\Models\System\Info {#1008}
>>> $info->toArray();
=> [
"version" => "v2016.6.43325",
"isCloud" => false,
"serverTimeZone" => "Eastern Standard Time",
]
>>> $info->toJson()
=> "{"version":"v2016.6.43325","isCloud":false,"serverTimeZone":"Eastern Standard Time"}"
>>> $info->isCloud
=> false
>>> $info['isCloud'];
=> false
$ php artisan tinker
Psy Shell v0.8.0 (PHP 7.0.14 — cli) by Justin Hileman
>>> Auth::loginUsingId(1);
PHP warning: unlink(/Users/jimmy.puckett/git/swaginator.com/storage/framework/sessions/1aMf1yhUe6h4Ij2GRvq5UYab1IqK7GVn1qkyWPY6): No such file or directory in /Users/jimmy.puckett/git/swaginator.com/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php on line 172
=> App\User {#983
id: "1",
first_name: "Joe",
last_name: "Doe",
email: "[email protected] ",
admin: "0",
created_at: "2017-01-02 18:30:47",
updated_at: "2017-01-12 22:22:39",
logged_in_at: "2017-01-12 22:22:39",
deleted_at: null,
}
>>> ConnectWise::get('system/info');
=> Spinen\ConnectWise\Models\System\Info {#1005}
>>> ConnectWise::get('system/info')->toArray();
=> [
"version" => "v2016.6.43325",
"isCloud" => false,
"serverTimeZone" => "Eastern Standard Time",
]
>>> ConnectWise::get('system/info')->toJson();
=> "{"version":"v2016.6.43325","isCloud":false,"serverTimeZone":"Eastern Standard Time"}"
>>> ConnectWise::get('system/info')->isCloud;
=> false
>>> ConnectWise::get('system/info')['isCloud'];
=> false
>>>
$ php -a
Interactive shell
php > // Autoload classes
php > se\Api\Token();
php > $guzzle = new GuzzleHttp\Client();
php > $resolver = new Spinen\ConnectWise\Support\ModelResolver();
php > $client = new Spinen\ConnectWise\Api\Client($token, $guzzle, $resolver);
php > // Now set your configs
php > $token->setCompanyId('<company_id>')->setMemberId('<member_id>');
php > $client->setIntegrator('<integrator>')->setPassword('<password>')->setUrl('https://<domain.tld>');
php > $info = $client->get('system/info');
php > var_export($info, false);
Spinen\ConnectWise\Models\System\Info::__set_state(array(
'casts' =>
array (
'version' => 'string',
'isCloud' => 'boolean',
'serverTimeZone' => 'string',
),
'attributes' =>
array (
'version' => 'v2016.6.43325',
'isCloud' => false,
'serverTimeZone' => 'Eastern Standard Time',
),
))
php > var_export($info->toArray(), false);
array (
'version' => 'v2016.6.43325',
'isCloud' => false,
'serverTimeZone' => 'Eastern Standard Time',
)
php > var_export($info->tojson(), false);
'{"version":"v2016.6.43325","isCloud":false,"serverTimeZone":"Eastern Standard Time"}'
php > var_export($info->isCloud, false);
false
php > var_export($info['isCloud'], false);
false
php >