{"id":22682010,"url":"https://github.com/shusaura85/fancourier-api","last_synced_at":"2025-07-15T01:10:16.434Z","repository":{"id":57050175,"uuid":"301407232","full_name":"shusaura85/fancourier-api","owner":"shusaura85","description":"PHP library to work with the new Fan Courier API v2.0 (selfawb.ro / api.fancourier.ro)","archived":false,"fork":false,"pushed_at":"2025-03-20T12:24:10.000Z","size":159,"stargazers_count":23,"open_issues_count":0,"forks_count":10,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-06-09T18:15:42.010Z","etag":null,"topics":["api-client","courier","fan","fan-courier","fancourier","json","json-api","library","php","php-library"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shusaura85.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-05T12:50:25.000Z","updated_at":"2025-04-20T20:21:36.000Z","dependencies_parsed_at":"2024-01-18T12:25:24.290Z","dependency_job_id":"5f2aa301-3bc9-4f45-b4f1-be8a0864fea1","html_url":"https://github.com/shusaura85/fancourier-api","commit_stats":{"total_commits":9,"total_committers":1,"mean_commits":9.0,"dds":0.0,"last_synced_commit":"1bd52d0d44b09f309ed07d39261dc58814960685"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/shusaura85/fancourier-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shusaura85%2Ffancourier-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shusaura85%2Ffancourier-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shusaura85%2Ffancourier-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shusaura85%2Ffancourier-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shusaura85","download_url":"https://codeload.github.com/shusaura85/fancourier-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shusaura85%2Ffancourier-api/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265383752,"owners_count":23756587,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-client","courier","fan","fan-courier","fancourier","json","json-api","library","php","php-library"],"created_at":"2024-12-09T20:17:10.623Z","updated_at":"2025-07-15T01:10:16.406Z","avatar_url":"https://github.com/shusaura85.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FANCourier API v2.0\n\n## Table of contents\n- \u003ca href=\"#information\"\u003eInformation\u003c/a\u003e\n- \u003ca href=\"#installation\"\u003eInstallation\u003c/a\u003e\n    - \u003ca href=\"#requirements\"\u003eRequirements\u003c/a\u003e\n    - \u003ca href=\"#composer\"\u003eComposer\u003c/a\u003e\n- \u003ca href=\"#usage\"\u003eUsage\u003c/a\u003e\n    - \u003ca href=\"#authentication\"\u003eAuthentication\u003c/a\u003e\n    - \u003ca href=\"#get-estimated-shipping-cost\"\u003eGet estimated shipping cost\u003c/a\u003e\n    - \u003ca href=\"#create-awb\"\u003eCreate AWB\u003c/a\u003e\n    - \u003ca href=\"#create-awb-in-bulk\"\u003eCreate AWB in bulk\u003c/a\u003e\n    - \u003ca href=\"#track-awb\"\u003eTrack AWB\u003c/a\u003e\n    - \u003ca href=\"#track-awb-in-bulk\"\u003eTrack awb in bulk\u003c/a\u003e\n    - \u003ca href=\"#fanbox\"\u003eFANBox\u003c/a\u003e\n    - \u003ca href=\"#print-awb\"\u003ePrint AWB (PDF)\u003c/a\u003e\n    - \u003ca href=\"#print-awb-zpl\"\u003ePrint AWB (ZPL)\u003c/a\u003e\n    - \u003ca href=\"#print-awb-html\"\u003ePrint AWB Html\u003c/a\u003e\n    - \u003ca href=\"#delete-awb\"\u003eDelete AWB\u003c/a\u003e\n- \u003ca href=\"#license\"\u003eLicense\u003c/a\u003e\n\n## Information\nThis version of the library is designed for FANCourier API v2.0 (JSON based responses). The code works and there are examples for all API requests, however, the documentation is not yet ready.  \n  \nAll requests have the method `getData()` that returns the unprocessed response of the API. Aditional functions depend on the response object type to return processed data.  \n\n## Installation\n### Requirements\n\n* PHP \u003e= 7.0\n\n**NOTE** At the moment it's designed to work with PHP 7.0 and newer.  \nHowever, the plan is to add type and return type declarations for all functions that will push the requirements to PHP 8.1 at the minimum  \n\n### Composer\nRequire the package via composer\n```bash\ncomposer require shusaura85/fancourier-api\n```\n\n### Manual\nIf used without composer, you will need to manually require the `autoload.php` file\n```php\nrequire_once '/path/to/fancourier-api/src/autoload.php';\n```\n\n## Usage\n\nAt the moment complete and proper documentation is not yet available. However, there are examples for every request type you can make.  \nInside them you will also find comments with complete function list for each `request`, `response` and `object`.\n\n\n### Authentication\nCreate a new instance of `Fancourier.php` supplying the `client_id`, `username`, `password` and `token`.\n```php\n$clientId = 'your_client_id';\n$username = 'your_username';\n$password = 'your_password';\n$token = 'load from cache or leave as empty string';\n\n$fan = new Fancourier\\Fancourier($clientId, $username, $password, $token);\n```\nOr you can use the test instance static method:\n```php\n$fan = Fancourier\\Fancourier::testInstance($token);\n```\n\nThe generated token has a life time of 24 hours and must be refreshed after this period. You can get the generated token using the function:\n```\n$force_refresh = false;\n$token = $fan-\u003egetToken($force_refresh);\n```\nIf the specified token is empty when creating the instance, it will be generated automatically on the first request.  \n\n\n### Get estimated shipping cost\nRequest\n```php\n$request = new Fancourier\\Request\\GetCosts();\n$request\n    -\u003esetParcels(1)\n    -\u003esetWeight(1)\n    -\u003esetCounty('Arad')\n    -\u003esetCity('Aciuta')\n    -\u003esetDeclaredValue(125);\n```\nResponse\n```php\nif ($response-\u003eisOk()) {\n    var_dump($response-\u003egetData()); // raw data\n    // or just the information you want\n    echo \"extraKmCost: \". $response-\u003egetKmCost().'\u003cbr /\u003e';\n    echo \"weightCost: \". $response-\u003egetWeightCost().'\u003cbr /\u003e';\n    echo \"insuranceCost: \". $response-\u003egetInsuranceCost().'\u003cbr /\u003e';\n    echo \"optionsCost: \". $response-\u003egetOptionsCost().'\u003cbr /\u003e';\n    echo \"fuelCost: \". $response-\u003egetFuelCost().'\u003cbr /\u003e';\n    echo \"costNoVAT: \". $response-\u003egetCost().'\u003cbr /\u003e';\n    echo \"vat: \". $response-\u003egetCostVat().'\u003cbr /\u003e';\n    echo \"total: \".$response-\u003egetCostTotal().'\u003cbr /\u003e';\n} else {\n    var_dump($response-\u003egetErrorMessage());\n    print_r($response-\u003egetAllErrors());\n}\n```\n\n### Create AWB\nRequest\n```php\n$awb = new Fancourier\\Objects\\AwbIntern();\n$awb\n    -\u003esetService('Cont Colector')\n    -\u003esetPaymentType(Fancourier\\Request\\CreateAwb::TYPE_SENDER)\n    -\u003esetParcels(1)\n    -\u003esetWeight(1)    // in kg\n    -\u003esetReimbursement(199.99) // suma de incasat\n    -\u003esetDeclaredValue(1000)\n    -\u003esetSizes(10,5,1) // in cm\n    -\u003esetNotes('testing notes')\n    -\u003esetContents('SKU-1, SKU-2')\n    -\u003esetRecipientName(\"John Ivy\")\n    -\u003esetPhone('0723000000')\n    -\u003esetCounty('Arad')\n    -\u003esetCity('Aciuta')\n    -\u003esetStreet('Str Lunga')\n    -\u003esetNumber(1)\n    -\u003eaddOption('S')\n    -\u003eaddOption('X');\n\n$request = new Fancourier\\Request\\CreateAwb();\n$request-\u003eaddAwb($awb);\n\n```\nResponse\n```php\n$response = $fan-\u003ecreateAwb($request);\n\nif ($response-\u003eisOk()) {\n    var_dump($response-\u003egetData()); // raw data\n    // or the AWBIntern objects updated with the response information\n    $al = $response-\u003egetAll();\n    echo \"Count: \".count($al).\"\u003cbr /\u003e\";\n    foreach ($al as $awbr)\n        {\n        if ($awbr-\u003ehasErrors())\n            {\n            print_r($awbr-\u003egetErrors());\n            }\n        else\n            {\n            echo \"AWB: \".$awbr-\u003egetAwb().\"\u003cbr /\u003e\";\n            }\n        }\n    \n} else {\n    var_dump($response-\u003egetErrorMessage());\n}\n```\n\n### Create AWB in bulk\n\nUnlike the previous version, there is no longer a CreateAwbBulk request. Simply create as many AWBIntern objects and add them to the request  \n  \nRequest\n```php\n$request = new Fancourier\\Request\\CreateAwb();\n\n// create the first awb\n$awb = new Fancourier\\Objects\\AwbIntern();\n$awb\n    -\u003esetService('Cont Colector')\n    ....\n    -\u003eaddOption('X');\n\n// add it to the request\n$request-\u003eaddAwb($awb);\n\n// create another awb\n$awb = new Fancourier\\Objects\\AwbIntern();\n$awb\n    -\u003esetService('Cont Colector')\n    ....\n    -\u003eaddOption('X');\n\n// add it to the request\n$request-\u003eaddAwb($awb);\n\n// create another awb\n$awb = new Fancourier\\Objects\\AwbIntern();\n$awb\n    -\u003esetService('Cont Colector')\n    ....\n    -\u003eaddOption('X');\n\n// add it to the request\n$request-\u003eaddAwb($awb);\n\n```\nResponse\n```php\n$response = $fan-\u003ecreateAwb($request);\n\nif ($response-\u003eisOk()) {\n    var_dump($response-\u003egetData()); // raw data\n    // or the AWBIntern objects updated with the response information\n    $al = $response-\u003egetAll();\n    echo \"Count: \".count($al).\"\u003cbr /\u003e\";\n    foreach ($al as $awbr)\n        {\n        if ($awbr-\u003ehasErrors())\n            {\n            print_r($awbr-\u003egetErrors());\n            }\n        else\n            {\n            echo \"AWB: \".$awbr-\u003egetAwb().\"\u003cbr /\u003e\";\n            }\n        }\n    \n} else {\n    var_dump($response-\u003egetErrorMessage());\n}\n```\n\n### Track AWB\nRequest\n```php\n$request = new Fancourier\\Request\\TrackAwb();\n$request\n    -\u003esetAwb('2150900120086');\n```\nResponse\n```php\n$response = $fan-\u003etrackAwb($request);\n\nif ($response-\u003eisOk()) {\n    print_r($response-\u003egetData()); // raw data\n    print_r($response-\u003egetAll()); // array of AwbTracker objects\n} else {\n    var_dump($response-\u003egetErrorMessage());\n}\n```\n\n### Track awb in bulk\n\nUnlike previous version, you can use the same TrackAwb() object and add as many AWB's as you need to Track  \n\nRequest\n```php\n$request = new Fancourier\\Request\\TrackAwb();\n$request\n    -\u003eaddAwb('2150900120084')\n    -\u003eaddAwb('2150900120085')\n    -\u003eaddAwb('2150900120086');\n```\nResponse\n```php\n$response = $fan-\u003etrackAwb($request);\n\nif ($response-\u003eisOk()) {\n    print_r($response-\u003egetData()); // raw data\n    print_r($response-\u003egetAll()); // array of AwbTracker objects\n} else {\n    var_dump($response-\u003egetErrorMessage());\n}\n```\n\n### FANBox\n\nYou can now easily get information about available FANBox and PayPoint locations. FAN Courier calls there PUDO (Pick Up Drop Off).  \nWhen creating an AWB for them, set the address to the PUDO address as received here as well as calling the function `setPickupLocation(PUDO_ID)` with the ID of the selected PUDO.  \n\nRequest\n```php\n$request = new Fancourier\\Request\\GetPudo();\n$request\n    -\u003esetType(Fancourier\\Request\\GetPudo::PUDO_FANBOX);\n```\nResponse\n```php\n$response = $fan-\u003egetPudo($request);\n\nif ($response-\u003eisOk()) {\n    print_r($response-\u003egetData()); // raw data\n    print_r($response-\u003egetAll()); // array of PUDO objects\n} else {\n    var_dump($response-\u003egetErrorMessage());\n}\n```\n\n### Print AWB\n\nThe print request can print one or more AWBs using a single request.  \nYou can specify the size of the AWB using the `-\u003esetSize()` function. Available options are: *empty*, **A4**, **A5** and **A6**. **A6** can only be used with ePod option.  \nPDF printing is the default mode of printing.  \nPlease note that you can't request ZPL and PDF at the same time. Using `setPdf()` will automatically disable ZPL option if set.  \n\nRequest\n```php\n$request = new Fancourier\\Request\\PrintAwb();\n$request\n    -\u003esetPdf(true)\n    -\u003esetAwb('2150900120086');\n```\nResponse\n```php\n$response = $fan-\u003eprintAwb($request);\nif ($response-\u003eisOk()) {\n    echo $response-\u003egetData();\n} else {\n    var_dump($response-\u003egetErrorMessage());\n    print_r($response-\u003egetAllErrors());\n}\n```\n\n### Print AWB ZPL\n\nYou can request the AWB in the ZPL format (Zebra Programming Language) for use with a label printer.  \nPlease note that you can't request ZPL and PDF at the same time. Using `setZpl()` will automatically disable PDF option if set.  \n\nRequest\n```php\n$request = new Fancourier\\Request\\PrintAwb();\n$request\n    -\u003esetZpl(true)\n    -\u003esetAwb('2150900120086');\n```\nResponse\n```php\n$response = $fan-\u003eprintAwb($request);\nif ($response-\u003eisOk()) {\n    echo $response-\u003egetData();\n} else {\n    var_dump($response-\u003egetErrorMessage());\n    print_r($response-\u003egetAllErrors());\n}\n```\n\n### Print AWB Html\n\nIf you want the AWB in a HTML format, just use -\u003esetPdf(false) to get HTML data instead of PDF.  \n\nRequest\n```php\n$request = new Fancourier\\Request\\PrintAwb();\n$request\n    -\u003esetPdf(false)\n    -\u003esetAwb('2150900120086');\n```\nResponse\n```php\n$response = $fan-\u003eprintAwb($request);\nif ($response-\u003eisOk()) {\n    echo $response-\u003egetData();\n} else {\n    var_dump($response-\u003egetErrorMessage());\n    print_r($response-\u003egetAllErrors());\n}\n```\n\n### Delete AWB\nRequest\n```php\n$request = new Fancourier\\Request\\DeleteAwb();\n$request-\u003esetAwb('2150900120086');\n```\nResponse\n```php\n$response = $fan-\u003edeleteAwb($request);\nif ($response-\u003eisOk()) {\n    var_dump($response-\u003egetData());\n} else {\n    var_dump($response-\u003egetErrorMessage());\n}\n```\n\n\n## License\n\nFancourier Api is open-source software licensed under the [MIT license](./LICENSE).\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshusaura85%2Ffancourier-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshusaura85%2Ffancourier-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshusaura85%2Ffancourier-api/lists"}