1. Go to this page and download the library: Download jpry/ynab-sdk-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use JPry\YNAB\Model\Mutation\CreateTransactionsRequest;
use JPry\YNAB\Model\Mutation\TransactionPayload;
use JPry\YNAB\Model\Mutation\UpdateTransactionRequest;
$client->createTransactions(
'plan-id',
CreateTransactionsRequest::single(
new TransactionPayload(accountId: 'account-id', amount: -1000)
),
);
$client->updateTransaction(
'plan-id',
new UpdateTransactionRequest('transaction-id', new TransactionPayload(memo: 'Updated memo')),
);
use JPry\YNAB\Client\YnabClient;
use JPry\YNAB\Config\ClientConfig;
$config = new ClientConfig();
$client = YnabClient::withOAuthToken(
accessToken: 'access-token',
refreshAccessToken: fn (): string => 'new-access-token',
config: $config,
);
use JPry\YNAB\Http\GuzzleRequestSender;
use JPry\YNAB\OAuth\OAuthClient;
use JPry\YNAB\OAuth\OAuthConfig;
use JPry\YNAB\Config\ClientConfig;
$oauth = new OAuthClient(
new OAuthConfig(
clientId: 'client-id',
clientSecret: 'client-secret',
redirectUri: 'https://example.com/oauth/callback',
),
new GuzzleRequestSender(new ClientConfig()),
);
$authUrl = $oauth->authorizationUrl('state-value');
$tokens = $oauth->exchangeCodeForTokens('code-from-callback');
use JPry\YNAB\Http\RequestSender;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use GuzzleHttp\Psr7\Response;
final class MySender implements RequestSender
{
public function sendRequest(RequestInterface $request): ResponseInterface
{
// Bridge to your own HTTP library
return new Response(200, [], '{"data":{}}');
}
}
$client = YnabClient::withApiKey('api-key', requestSender: new MySender());
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.