-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathFavorite.php
32 lines (28 loc) · 1.14 KB
/
Favorite.php
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
<?php
/**
* ©[2025] SugarCRM Inc. Licensed by SugarCRM under the Apache 2.0 license.
*/
require_once 'include.php';
$SugarAPI = new \Sugarcrm\REST\Client\SugarApi($server, $credentials);
try {
if ($SugarAPI->isAuthenticated()) {
echo "Logged In: " . json_encode($SugarAPI->getAuth()->getToken(), JSON_PRETTY_PRINT) . "\n";
//Create a new Account
$Account = $SugarAPI->module('Accounts')->set("name", "Favorite Test");
$Account->save();
echo "Account Created: {$Account['id']}\n";
$Account->favorite();
echo "Account added to Favorites: " . ($Account->my_favorite ? "TRUE" : "FALSE") . "\n";
} else {
echo "Could not login.";
$oauthEndpoint = $SugarAPI->getAuth()->getActionEndpoint('authenticate');
$response = $oauthEndpoint->getResponse();
if ($response) {
$statusCode = $oauthEndpoint->getResponse()->getStatusCode();
echo "[$statusCode] - " . $oauthEndpoint->getResponse()->getBody()->getContents();
}
}
} catch (Exception $ex) {
echo "Exception Occurred: " . $ex->getMessage();
echo $ex->getTraceAsString();
}