-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathprogrammatic_oauth_example.php
More file actions
34 lines (25 loc) · 1.15 KB
/
Copy pathprogrammatic_oauth_example.php
File metadata and controls
34 lines (25 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Penneo\SDK\ApiConnector;
use Penneo\SDK\CaseFile;
use Penneo\SDK\OAuth\Config\Environment;
use Penneo\SDK\OAuth\OAuthBuilder;
use Penneo\SDK\OAuth\Tokens\SessionTokenStorage;
session_start();
// set up where to store the tokens - either use the provided session storage
$tokenStorage = new SessionTokenStorage('optionalKeyToPlaceTokensInto');
// or build a custom one by implementing the interface
// $tokenStorage = new class implements \Penneo\SDK\OAuth\Tokens\TokenStorage {};
$penneoOAuth = OAuthBuilder::start()
->setEnvironment(Environment::SANDBOX)
->setClientId('clientId') // <- the credentials provided by Penneo
->setClientSecret('clientSecret') // <-
->setTokenStorage($tokenStorage)
->setApiKey('apiKey') // <- the api credentials found in your
->setApiSecret('apiSecret') // <- penneo users settings
->build();
ApiConnector::initializeOAuth($penneoOAuth);
$casefile = new CaseFile();
$casefile->setTitle('new test casefile from PHP');
CaseFile::persist($casefile);
var_dump($casefile);