Sapistudio / MyAudi

access to the MyAudi api
MIT License
9 stars 4 forks source link

How to get started? #1

Open andig opened 3 years ago

andig commented 3 years ago

Hey, I'm developer of XX and trying to better understand the VW/Audi APIs. I've tried to run this library but couldn't get it working:

<?php

use SapiStudio\MyAudi\Init;

require 'vendor/autoload.php';

$configure = [
    'username' => 'xxx',
    'password' => 'xxx',
    'HERE_API_KEY'=>'apivalue'
];

$myAudiHandler = Init::configure($configure);

// $myAudiHandler = Init::make();

$myAudiHandler->getPosition();
Init::logout();

composer install has run, but I'm unable to run the code above:

❯ php test.php         
PHP Notice:  Undefined index: validity in /Users/andig/htdocs/MyAudi/vendor/sapistudio/http/src/Browser/StreamClient.php on line 246

Notice: Undefined index: validity in /Users/andig/htdocs/MyAudi/vendor/sapistudio/http/src/Browser/StreamClient.php on line 246
PHP Notice:  Undefined index: TOKEN_AUDI in /Users/andig/htdocs/MyAudi/src/ApiConnect.php on line 164

Notice: Undefined index: TOKEN_AUDI in /Users/andig/htdocs/MyAudi/src/ApiConnect.php on line 164
PHP Notice:  Undefined variable: method in /Users/andig/htdocs/MyAudi/vendor/sapistudio/restapi/src/AbstractHttpClient.php on line 191

Notice: Undefined variable: method in /Users/andig/htdocs/MyAudi/vendor/sapistudio/restapi/src/AbstractHttpClient.php on line 191
PHP Notice:  Undefined variable: path in /Users/andig/htdocs/MyAudi/vendor/sapistudio/restapi/src/AbstractHttpClient.php on line 192

Notice: Undefined variable: path in /Users/andig/htdocs/MyAudi/vendor/sapistudio/restapi/src/AbstractHttpClient.php on line 192
PHP Notice:  Undefined index: base_uri in /Users/andig/htdocs/MyAudi/vendor/sapistudio/restapi/src/AbstractHttpClient.php on line 151

Notice: Undefined index: base_uri in /Users/andig/htdocs/MyAudi/vendor/sapistudio/restapi/src/AbstractHttpClient.php on line 151
PHP Fatal error:  Uncaught Exception: Invalid response: Invalid credentials in /Users/andig/htdocs/MyAudi/src/ApiConnect.php:295
Stack trace:
#0 /Users/andig/htdocs/MyAudi/vendor/sapistudio/restapi/src/AbstractHttpClient.php(164): SapiStudio\MyAudi\ApiConnect->validateApiResponse(Array)
#1 /Users/andig/htdocs/MyAudi/vendor/sapistudio/restapi/src/AbstractHttpClient.php(105): SapiStudio\RestApi\AbstractHttpClient->startRequest('POST', 'https://id.audi...', Array, NULL)
#2 /Users/andig/htdocs/MyAudi/src/ApiConnect.php(170): SapiStudio\RestApi\AbstractHttpClient->cachedPostRequest(NULL, 'https://id.audi...', Array)
#3 /Users/andig/htdocs/MyAudi/src/ApiConnect.php(120): SapiStudio\MyAudi\ApiConnect->registerApp()
#4 /Users/andig/htdocs/MyAudi/src/ApiConnect.php(109): SapiStudio\MyAudi\ApiConnect->initAudiApp()
#5 /Users/andig/htdocs/MyAudi/src/ApiConnect.php(46): SapiStudio\MyAudi\ApiConnect->__construct()
#6 /Users/andig/htdocs/MyAudi/src/ApiConnect.php(32): SapiStudio\MyAudi\ApiConnect::make()
#7 /Users/andig/htdocs/MyAudi/test.p in /Users/andig/htdocs/MyAudi/src/ApiConnect.php on line 295

Fatal error: Uncaught Exception: Invalid response: Invalid credentials in /Users/andig/htdocs/MyAudi/src/ApiConnect.php:295
Stack trace:

...

Is there any way to dump the HTTP requests or can you spot ad-hoc what's wrong? The warnings can probably be ignored but would still be nice to get rid of.

Sapistudio commented 3 years ago

Hello, the api has changed,that's why you get "Invalid response: Invalid credentials". I am working on updating this