Skip to content

Instantly share code, notes, and snippets.

@yatakeke
Last active February 18, 2019 01:56
Show Gist options
  • Save yatakeke/aaba4433df7f5afac6809b4569f0776f to your computer and use it in GitHub Desktop.
Save yatakeke/aaba4433df7f5afac6809b4569f0776f to your computer and use it in GitHub Desktop.
methods to create and build app in heroku
<?php
public function createapp($email, $password){
$url = "https://api.heroku.com/apps";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_USERPWD, $email.":".$password);
$headers = ['Accept: application/vnd.heroku+json; version=3',"Content-Type: application/json"];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
return json_decode($result);
}
public function buildapp($email, $password, $appname, $datapath){
$url = "https://api.heroku.com/apps/".$appname."/builds";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_USERPWD, $email.":".$password);
$headers = ['Accept: application/vnd.heroku+json; version=3',"Content-Type: application/json"];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$data = '{"source_blob":{"url":'.'"'.$datapath.'"}}';
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$result = curl_exec($ch);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment