private function CreateIssue() { $response = ''; switch ($this->data['vcs']) { case 'github': require_once 'api/github_api.php'; $githubObj = new GitHubAPI(); $response = $githubObj->CreateIssue($this->data); break; case 'bitbucket': require_once 'api/bitbucket_api.php'; $githubObj = new BitBucketAPI(); $response = $githubObj->CreateIssue($this->data); break; } return $response; }
On the Bitbucket account: {$account} Using the login username '{$username}' Do you want to continue (y/n)? EOD; $response = ''; while (!in_array(trim(strtolower($response)), array('y', 'n', 'yes', 'no'))) { $response = trim(fgets(STDIN)); } if (in_array(trim(strtolower($response)), array('n', 'no'))) { echo "Quitting script" . PHP_EOL; exit(0); } echo "Reading in list of repositories from Bitbucket repositories/{$account}\n\n"; $api = new BitBucketAPI($username, $password); $repos = $api->listRepositories($account); echo "\n"; // Initial method // $repoPattern = '!https://bitbucket.org/api/2.0/repositories/' . $account . '/(.+)/watchers$!'; // Second method (Aug 4, 2015) // $repoPattern = '!https://api.bitbucket.org/2.0/repositories/' . $account . '/(.+)/hooks$!'; // New Method (Aug 7, 2015) $repoPattern = '!https://bitbucket.org/\\!api/2.0/repositories/' . $account . '/(.+)/hooks$!'; foreach ($repos->values as $repo) { if (preg_match($repoPattern, $repo->links->hooks->href, $m)) { $url = $m[1]; } else { echo "Cannot match URL from " . $repo->links->hooks->href . PHP_EOL; continue; }
On the Bitbucket account: {$account} Using the login username '{$username}' Do you want to continue (y/n)? EOD; $response = ''; while (!in_array(trim(strtolower($response)), array('y', 'n', 'yes', 'no'))) { $response = trim(fgets(STDIN)); } if (in_array(trim(strtolower($response)), array('n', 'no'))) { echo "Quitting script" . PHP_EOL; exit(0); } echo "Reading in list of repositories from Bitbucket repositories/{$account}\n\n"; $api = new BitBucketAPI($username, $password); $repos = $api->listRepositories($account); echo "\n"; // Initial method // $repoPattern = '!https://api.bitbucket.org/2.0/repositories/' . $account . '/(.+)/hooks$!'; $repoPattern = '!https://bitbucket.org/\\!api/2.0/repositories/' . $account . '/(.+)/hooks$!'; foreach ($repos->values as $repo) { if (preg_match($repoPattern, $repo->links->hooks->href, $m)) { $url = $m[1]; } else { echo "Cannot match URL from " . $repo->links->hooks->href . PHP_EOL; continue; } echo "Testing repository: {$url}\n"; $webhooks = $api->getRepositoryWebhooks($account, $url); $slackIntegrated = false;