-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtoken.php
35 lines (27 loc) · 898 Bytes
/
token.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/php -q
<?php
// Copyright (C) 2017, Ward Mundy & Associates LLC with MIT license
include_once("config.php");
// Get cURL resource
$curl = curl_init();
$params = array(
'grant_type' => 'password',
'client_id' => $tesla_client_id,
'client_secret' => $tesla_client_secret,
'email' => $tesla_email,
'password' => $tesla_password,
);
var_dump($params);
curl_setopt($curl, CURLOPT_URL, "https://owner-api.teslamotors.com/oauth/token");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_HEADER, FALSE);
curl_setopt($curl, CURLOPT_POST, TRUE);
curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
// Send the request & save response to $resp
$resp = curl_exec($curl);
// Close request to clear up some resources
curl_close($curl);
file_put_contents("token",$resp);
echo "Done. Tokens written to file: token";
echo $resp;
?>