コード例 #1
0
<?php

require_once __DIR__ . '/../vendor/autoload.php';
try {
    $SugarAPI = new \SugarAPI\SDK\SugarAPI('instances.this/Pro/7621/', array('username' => 'admin', 'password' => 'asdf'));
    $SugarAPI->login();
    $EP = $SugarAPI->createRecord('Accounts');
    $data = array('name' => 'Test Record 4', 'email1' => '*****@*****.**');
    $response = $EP->execute($data)->getResponse();
    if ($response->getStatus() == '200') {
        $record = $response->getBody(false);
        $EP2 = $SugarAPI->getRecord('Accounts', $record->id)->execute(array('fields' => 'name,email1'));
        $getResponse = $EP2->getResponse();
        print $EP2->getUrl();
        print_r($getResponse->getBody());
    }
} catch (\SugarAPI\SDK\Exception\AuthenticationException $ex) {
    print $ex->getMessage();
}
コード例 #2
0
<?php

require_once __DIR__ . '/../vendor/autoload.php';
try {
    $SugarAPI = new \SugarAPI\SDK\SugarAPI('instances.this/Ent/7700/', array('username' => 'admin', 'password' => 'asdf'));
    $SugarAPI->login();
    $EP = $SugarAPI->createRecord('Notes')->execute(array('name' => 'Test Note'));
    $response = $EP->getResponse();
    if ($response->getStatus() == '200') {
        $record = $response->getBody(false);
        $upload = $SugarAPI->attachFile('Notes', $record->id, 'filename')->execute(__DIR__ . '/testfile.txt');
        $response = $upload->getResponse();
        if ($response->getStatus() == '200') {
            $record = $response->getBody();
            print_r($record);
        } else {
            print_r($upload->getRequest());
            echo "Failed to Update Note with File<br>";
            echo "Response: " . $response->getStatus() . "<br>";
            print_r($response->getBody());
        }
    } else {
        echo "Failed to create Note<br>";
        echo "Response: " . $response->getStatus() . "<br>";
        print_r($response->getBody());
    }
} catch (\SugarAPI\SDK\Exception\SDKException $ex) {
    print $ex->getMessage();
}