Skip to content

Instantly share code, notes, and snippets.

@doublejosh
Created January 12, 2015 22:41
Show Gist options
  • Select an option

  • Save doublejosh/471b1d374d69f84a83d1 to your computer and use it in GitHub Desktop.

Select an option

Save doublejosh/471b1d374d69f84a83d1 to your computer and use it in GitHub Desktop.
Request function example
/**
* 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