Created
January 12, 2015 22:41
-
-
Save doublejosh/471b1d374d69f84a83d1 to your computer and use it in GitHub Desktop.
Request function example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Send the request to retrigger a build. | |
| * | |
| * @param int $build_id | |
| * Travis build id to act upon, for URL construction. | |
| * @param string $token | |
| * Travis user authorization token. | |
| * @return array | |
| * Response items the calling function(s) might care about. | |
| */ | |
| function _travisbuilder_trigger_request($build_id) { | |
| $configs = _travisbuilder_configs(); | |
| $api_url = ($configs['private']) ? TRAVISBUILDER_API_PAID : TRAVISBUILDER_API_FREE; | |
| $url = sprintf('%s/builds/%s/restart.json', $api_url, $build_id); | |
| $headers = array( | |
| 'Authorization' => 'token ' . $configs['access_token'], | |
| ); | |
| $response = drupal_http_request($url, array( | |
| 'data' => '', | |
| 'headers' => $headers, | |
| 'timeout' => 5, | |
| 'method' => 'POST', | |
| )); | |
| return array( | |
| 'data' => $response->data, | |
| 'status_message' => $response->status_message, | |
| 'code' => $response->code, | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment