PHP code example of buddy-works / buddy-works-php-api
1. Go to this page and download the library: Download buddy-works/buddy-works-php-api 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/ */
buddy-works / buddy-works-php-api example snippets
$buddy = new Buddy\Buddy([
'clientId' => 'your-client-id',
'clientSecret' => 'your-client-secret'
]);
try {
$url = $buddy->getOAuth()->getAuthorizeUrl([
Buddy\BuddyOAuth::SCOPE_MANAGE_EMAILS
], 'state', 'redirectUrl');
} catch(Buddy\Exceptions\BuddySDKException $e) {
echo 'Buddy SDK return an error: ' . $e->getMessage();
exit;
}
$buddy = new Buddy\Buddy([
'clientId' => 'your-client-id',
'clientSecret' => 'your-client-secret'
]);
try {
$auth = $buddy->getOAuth()->getAccessToken('state');
} catch(Buddy\Exceptions\BuddyResponseException $e) {
echo 'Buddy API return an error: ' . $e->getMessage();
exit;
} catch(Buddy\Exceptions\BuddySDKException $e) {
echo 'Buddy SDK return an error: ' . $e->getMessage();
exit;
}
var_dump($auth);
$buddy = new Buddy\Buddy([
'accessToken' => 'your access token'
]);
try {
$resp = $buddy->getApiWorkspaces()->getWorkspaces([$accessToken]);
var_dump($resp);
exit;
} catch (Buddy\Exceptions\BuddyResponseException $e) {
echo $e->getMessage();
exit;
} catch (Buddy\Exceptions\BuddySDKException $e) {
echo $e->getMessage();
exit;
}
$buddy->getApiWorkspaces()->getWorkspace($domain, [$accessToken]);
$buddy->getApiWebhooks()->getWebhooks($domain, [$accessToken]);
$buddy->getApiWebhooks()->addWebhook($data, $domain, [$accessToken]);
$buddy->getApiWebhooks()->getWebhook($domain, $webhookId, [$accessToken]);
$buddy->getApiWebhooks()->editWebhook($data, $domain, $webhookId, [$accessToken]);
$buddy->getApiWebhooks()->deleteWebhook($domain, $webhookId, [$accessToken]);
$buddy->getApiTags()->getTags($domain, $projectName, [$accessToken]);
$buddy->getApiTags()->getTag($domain, $projectName, $name, [$accessToken]);
$buddy->getApiSshKeys()->getKeys([$accessToken]);
$buddy->getApiSshKeys()->addKey($data, [$accessToken]);
$buddy->getApiSshKeys()->deleteKey($keyId, [$accessToken]);
$buddy->getApiSshKeys()->getKey($keyId, [$accessToken]);
$buddy->getApiSource()->getContents($domain, $projectName, [$path], [$filters], [$accessToken]);
$buddy->getApiSource()->addFile($data, $domain, $projectName, [$accessToken]);
$buddy->getApiSource()->editFile($data, $domain, $projectName, $path, [$accessToken]);
$buddy->getApiSource()->deleteFile($data, $domain, $projectName, $path, [$accessToken]);
$buddy->getApiProjects()->getProjects($domain, [$filters], [$accessToken]);
$buddy->getApiProjects()->addProject($data, $domain, [$accessToken]);
$buddy->getApiProjects()->getProject($domain, $projectName, [$accessToken]);
$buddy->getApiProjects()->editProject($data, $domain, $projectName, [$accessToken]);
$buddy->getApiProjects()->deleteProject($domain, $projectName, [$accessToken]);
$buddy->getApiProjects()->getProjectMembers($domain, $projectName, [$filters], [$accessToken]);
$buddy->getApiProjects()->addProjectMember($domain, $projectName, $userId, $permissionId, [$accessToken]);
$buddy->getApiProjects()->getProjectMember($domain, $projectName, $userId, [$accessToken]);
$buddy->getApiProjects()->editProjectMember($domain, $projectName, $userId, $permissionId, [$accessToken]);
$buddy->getApiProjects()->deleteProjectMember($domain, $projectName, $userId, [$accessToken]);
$buddy->getApiProfile()->getAuthenticatedUser([$accessToken]);
$buddy->getApiProfile()->editAuthenticatedUser($data, [$accessToken]);
$buddy->getApiPipelines()->getPipelines($domain, $projectName, [$filters], [$accessToken]);
$buddy->getApiPipelines()->addPipeline($data, $domain, $projectName, [$accessToken]);
$buddy->getApiPipelines()->getPipeline($domain, $projectName, $pipelineId, [$accessToken]);
$buddy->getApiPipelines()->editPipeline($data, $domain, $projectName, $pipelineId, [$accessToken]);
$buddy->getApiPipelines()->deletePipeline($domain, $projectName, $pipelineId, [$accessToken]);
$buddy->getApiPipelines()->getPipelineActions($domain, $projectName, $pipelineId, [$accessToken]);
$buddy->getApiPipelines()->addPipelineAction($data, $domain, $projectName, $pipelineId, [$accessToken]);
$buddy->getApiPipelines()->getPipelineAction($domain, $projectName, $pipelineId, $actionId, [$accessToken]);
$buddy->getApiPipelines()->editPipelineAction($data, $domain, $projectName, $pipelineId, $actionId, [$accessToken]);
$buddy->getApiPipelines()->deletePipelineAction($domain, $projectName, $pipelineId, $actionId, [$accessToken]);
$buddy->getApiPermissions()->getWorkspacePermissions($domain, [$accessToken]);
$buddy->getApiPermissions()->addWorkspacePermission($data, $domain, [$accessToken]);
$buddy->getApiPermissions()->getWorkspacePermission($domain, $permissionId, [$accessToken]);
$buddy->getApiPermissions()->editWorkspacePermission($data, $domain, $permissionId, [$accessToken]);
$buddy->getApiPermissions()->deleteWorkspacePermission($domain, $permissionId, [$accessToken]);
$buddy->getApiMembers()->getWorkspaceMembers($domain, [$filters], [$accessToken]);
$buddy->getApiMembers()->addWorkspaceMember($domain, $email, [$accessToken]);
$buddy->getApiMembers()->getWorkspaceMember($domain, $userId, [$accessToken]);
$buddy->getApiMembers()->editWorkspaceMember($domain, $userId, $isAdmin, [$accessToken]);
$buddy->getApiMembers()->deleteWorkspaceMember($domain, $userId, [$accessToken]);
$buddy->getApiMembers()->getWorkspaceMemberProjects($domain, $userId, [$filters], [$accessToken]);
$buddy->getApiIntegrations()->getIntegrations([$accessToken]);
$buddy->getApiIntegrations()->getIntegration($integrationId, [$accessToken]);
$buddy->getApiGroups()->getGroups($domain, [$accessToken]);
$buddy->getApiGroups()->addGroup($data, $domain, [$accessToken]);
$buddy->getApiGroups()->getGroup($domain, $groupId, [$accessToken]);
$buddy->getApiGroups()->editGroup($data, $domain, $groupId, [$accessToken]);
$buddy->getApiGroups()->deleteGroup($domain, $groupId, [$accessToken]);
$buddy->getApiGroups()->getGroupMembers($domain, $groupId, [$accessToken]);
$buddy->getApiGroups()->addGroupMember($domain, $groupId, $userId, [$accessToken]);
$buddy->getApiGroups()->getGroupMember($domain, $groupId, $userId, [$accessToken]);
$buddy->getApiGroups()->deleteGroupMember($domain, $groupId, $userId, [$accessToken]);
$buddy->getApiExecutions()->getExecutions($domain, $projectName, $pipelineId, [$filters], [$accessToken]);
$buddy->getApiExecutions()->runExecution($data, $domain, $projectName, $pipelineId, [$accessToken]);
$buddy->getApiExecutions()->getExecution($domain, $projectName, $pipelineId, $executionId, [$accessToken]);
$buddy->getApiExecutions()->cancelExecution($domain, $projectName, $pipelineId, $executionId, [$accessToken]);
$buddy->getApiExecutions()->retryRelease($domain, $projectName, $pipelineId, $executionId, [$accessToken]);
$buddy->getApiEmails()->getAuthenticatedUserEmails([$accessToken]);
$buddy->getApiEmails()->addAuthenticatedUserEmail($email, [$accessToken]);
$buddy->getApiEmails()->deleteAuthenticatedUserEmail($email, [$accessToken]);
$buddy->getApiCommits()->getCommits($domain, $projectName, [$filters], [$accessToken]);
$buddy->getApiCommits()->getCommit($domain, $projectName, $revision, [$accessToken]);
$buddy->getApiCommits()->getCompare($domain, $projectName, $base, $head, [$filters], [$accessToken]);
$buddy->getApiBranches()->getBranches($domain, $projectName, [$accessToken]);
$buddy->getApiBranches()->getBranch($domain, $projectName, $name, [$accessToken]);
$buddy->getApiBranches()->addBranch($data, $domain, $projectName, [$accessToken]);
$buddy->getApiBranches()->deleteBranch($domain, $projectName, $name, [$force], [$accessToken]);