andig / carddav2fb

Download CardDAV VCards and upload as phonebook to AVM FRITZ!Box
63 stars 19 forks source link

Simplify file upload #96

Closed andig closed 5 years ago

andig commented 5 years ago

Fixed #78. 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;
derwok commented 5 years ago

Hi, I just checked out jour /api/ branch (this PR) and gave it a test run. I don't know if this is already ment to work?

On my machine I get this error at the very end:

Converted 138 vCard(s)
Uploading
PHP Fatal error:  Uncaught Error: Call to undefined method Andig\FritzBox\Api::doPostFile() in /home/pi/bin/carddav2fb/src/functions.php:363
Stack trace:
#0 /home/pi/bin/carddav2fb/src/RunCommand.php(95): Andig\upload('<?xml version="...', Array)
#1 /home/pi/bin/carddav2fb/vendor/symfony/console/Command/Command.php(255): Andig\RunCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#2 /home/pi/bin/carddav2fb/vendor/symfony/console/Application.php(953): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /home/pi/bin/carddav2fb/vendor/symfony/console/Application.php(248): Symfony\Component\Console\Application->doRunCommand(Object(Andig\RunCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 /home/pi/bin/carddav2fb/vendor/symfony/console/Application.php(148): Symfony\Component\Console\Appli in /home/pi/bin/carddav2fb/src/functions.php on line 363
andig commented 5 years ago

Ja, das muss postFile heissen wie oben geschrieben.