deployhuman/fortnox-client

用于访问Fortnox API的客户端

dev-master 2022-12-08 20:18 UTC

This package is auto-updated.

Last update: 2024-09-08 23:46:48 UTC


README

  • API

本客户端旨在提供一个简单的访问瑞典公司Fortnox API的接口。

所有帮助都受感激

Composer

使用 Composer 安装

只需输入

composer require deployhuman/fortnox-client dev-master

安装完成!

入门

<?php
require_once(__DIR__ . '/vendor/autoload.php');

//starting a Config Instance, setting up the bare minimum
$Config = (new \DeployHuman\fortnox\Configuration())
  ->setAppID('The Application you want the user to connect to')
  ->setClient_id('Your API pre-known Client Id')
  ->setClient_secret('Your API pre-known Client Secret');

//add config to the Client to create and api instance
$apiInstance = new \DeployHuman\fortnox\ApiClient($Config);

//generate a link for the user to visit, which allows this App to edit the Fortnox Account.
$AcceptAdminLink = $apiInstance->Authentication()->createAuthLink('mydomain.com/Validation','bookkeeping%20companyinformation');

//User clicks the link, and you get a query back, thats the $Auth_Code which you use to get Full tokens
$response = $apiInstance->Authentication()->callAPIExchangeCodeForTokens($Auth_Code);
$body = (array) json_decode($response->getBody()->getContents(), true);

// $body["access_token"] is the most important, this you save in the database.
// When using the callAPIExchangeCodeForTokens and callAPIRefreshAccessToken it will automaticly set the Token from that response to the ApiInstance itself.
// You still need to save it for later, as the Application always needs the latest to function.
// And when you restart the Instance, you need to set the Token you have saved. Otherwise needs to Use link again.

//When tokens is saved, start using the Instance for your needs.
$response = $apiInstance->Fortnox()->CompanyInformation()->apiGETCompanyInformation();

API端点文档

请查看 https://developer.fortnox.se/

我将添加有关发票的最基本信息。