Last active
February 18, 2019 01:56
-
-
Save yatakeke/aaba4433df7f5afac6809b4569f0776f to your computer and use it in GitHub Desktop.
methods to create and build app in heroku
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
<?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