jens-maus / carddav2fb

:notebook: A command-line PHP script allowing to import CardDAV-based VCards (e.g. from 'owncloud') to a phonebook in a AVM FRITZ!Box
The Unlicense
28 stars 19 forks source link

Simplify file upload #46

Closed andig closed 5 years ago

andig commented 5 years ago

Usage example:

#!/usr/bin/env php
<?php

use Andig\FritzBox\Api;

require_once('vendor/autoload.php');

$api = new Api('http://fritz.box', 'foo', 'bar');

echo $api->getSID();

$formfields = array(
    'PhonebookId' => 1
);

$filefields = array(
    'PhonebookImportFile' => array(
        'type' => 'text/xml',
        'filename' => 'updatepb.xml',
        'content' => 'foobarbaz',
    )
);

$result = $api->postFile($formfields, $filefields); // send the command
echo $result;

fixes #78