Skip to content

Commit

Permalink
Add 'lib/fritzbox_api_php/' from commit 'ccb600a9bf808aa43b5e9874032c…
Browse files Browse the repository at this point in the history
…5c4552634f30'

git-subtree-dir: lib/fritzbox_api_php
git-subtree-mainline: 1ced5f3
git-subtree-split: ccb600a
  • Loading branch information
jens-maus committed Sep 6, 2015
2 parents 1ced5f3 + ccb600a commit a1d667e
Show file tree
Hide file tree
Showing 14 changed files with 1,497 additions and 0 deletions.
79 changes: 79 additions & 0 deletions lib/fritzbox_api_php/CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
0.5.0b7 2013-01-02:
---

* added a parameter to the constructor of the api to load a different config file (i.e. new frizbox_api('alt') loads fritzbox_user_alt.conf.php
* fixed the logfile-logging in all bundled scripts


0.5.0b6 2012-12-23:
---

* added a username config item to login with a local user, when user-based login is enabled in the box config


0.5.0b5 2012-12-18:
---

* fixed the remoteconfig login code to work with new user system
* fixed the logger calls to echo the message, when the logger is not initialized


0.5.0b4 2012-12-16:
---

* fixed a typo in the remoteconfig login code


0.5.0b3 2012-12-09:
---

* changed fritzbox_get_foncallslist.php to work with new firmwares, moved old method to fritzbox_get_foncallslist_xml.php


0.5.0b3 2012-12-07:
---

* fixed internal SID login/logut-handling


0.5.0b1 2012-12-05:
---

* added support for the new .lua-loginpage in newest Fritz Labor firmwares
* refactored the whole codebase, introduced a new autoloaded config object, so check the new config file fritzbox_user.conf.php


0.4.1 2012-03-15:
---

* added a new script fritzbox_guestlan_on_off.php to switch the new Guest-LAN on and off
* tested all builtin scripts with new FRITZ!OS 05.20


0.4 2011-05-15:
---

* added support for the new .lua forms like the WLAN guest access settings


0.3 2010-05-19:
---

* added a doGetRequest method in the API
* some minor changes
* a new module for downloading the foncalls list


0.2 2010-04-07:
---

* added a capability to use the Fritz!Box remote admin mode
Important limitation: does not check the certificate, so the password is sent to any computer responding at the configured address.
Feel free to hack the cURL calls to accept only a given certrificate


0.1:
---

* First release

80 changes: 80 additions & 0 deletions lib/fritzbox_api_php/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# FritzBox! PHP API

Provides an interface to your FritzBox! using the webinterface. Thus, no modification the to firmware (aka FritzOS) is required!

### Requirements
* PHP 5 (tested with 5.3)
* PHP-curl

Install on Debian/Ubuntu: sudo apt-get install php5-cli php5-curl

###Sample Scripts

* Enable/Disable TAM
* Download Phone call list
* Enable/Disable Guest (W)LAN
* Ring a Phone
* Reboot
* Export the Phonebook
* **Import the Phonebook (only tested with FB 71xx) [not available in the original version]**

**Newer Version available at**: [IPF discussion thread](http://www.ip-phone-forum.de/showthread.php?t=196309)

AUTHORS: [Gregor Nathanael Meyer](http://spackmat.de/spackblog), Karl Glatz, (maybe others)

----------

### Important! ###
Do not use Windows Notepad as it will break the files due to their UTF-8 coding and UNIX linebreaks. Download a serious editor like Notepad++ instead.
Also do not use or modify this scripts, if you do not know, what you do. This script is itended for advanced users



### Basic usage advisory ####

The scripts are well documented, please take a look to understand them.
This is also the right moment to check the config file "fritzbox.conf.php"!

All files must be in the same directory. If this condition is fulfilled, you don't need to pay any more attention to "fritzbox_api.class.php".

To use "fritzbox_tam_on_off.php", you have to call it in a terminal, it will then explain its usage. This script is a reference implementation of the PHP Fritz!Box API, use it as a base for your own implementations



### Usage on a Windows system ###

The script works fine on my Windows Vista machine and a simply extraced PHP 5.3.0 distribution (get it at http://windows.php.net/download/, PHP 5.4.0 works as well). The cURL extension and the mbstring extenstion must be enabled in the php.ini and the correct timezone must be set. To do this, copy the php.ini-production to php.ini and uncomment/change the following directives:

extension_dir = "ext"
extension=php_curl.dll
extension=php_mbstring.dll
date.timezone = Europe/Berlin

After you have done that, you can call the script in a terminal:

C:\>path\to\php.exe path\to\fritzbox_tam_on_off.php

i.e. if you extracted PHP to c:\php and the Fritz!Box PHP API to a subfolder named fritz_api, you call it this way:
C:\>cd php
C:\php>php fritz_api\fritzbox_tam_on_off.php

If you use the Windows taskplanner, configure the logger to a logfile or to silent mode and call via php-win.exe instead of php.exe. This will prevent the terminal from being opened.



### Usage on a UNIX system ###

If you use UNIX, you should be familiar with calling a PHP script via the PHP-CLI. If you don't have the PHP-CLI installed, you can edit the $argv part in "fritz_tam_on_off.php" to work with PHP-CGI and $_GET or you hardcode the necessary arguments.

Ensure that the cURL and the mbstring extensions are available and a valid timezone is set. The script was tested on a Ubuntu Server machine with PHP 5.2.



### Feedback, license, support ###
You are welcome to send me feedback via email (Gregor [at] der-meyer.de) or visit my personal blog at http://spackmat.de/spackblog (in German)

The whole work is licensed under a Creative Commons cc-by-sa license (http://creativecommons.org/licenses/by-sa/3.0/de/). You are free to use and modify it, even for commercial use. If you redistribute it, you have to ensure my name is kept in the code and you use the same conditions.

Feel free to add (and contribute) other nice scripts. The API class should work with any config item, which is available in the Fritz!Box Web UI. Use Firebug or LiveHeaders to figure out the name of the proper POST-Field.

I won't give any personal support for this script, unless you pay for it. :) I'm a freelance IT-consultant and webdeveloper, loocated in Düsseldorf, Germany.
58 changes: 58 additions & 0 deletions lib/fritzbox_api_php/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
### Important! ###
Do not use Windows Notepad as it will break the files due to their UTF-8 coding and UNIX linebreaks. Download a serious editor like Notepad++ instead.
Also do not use or modify this scripts, if you do not know, what you do. This script is itended for advanced users


### Upgrade advisory for version 0.5.0 and up ####

Version 0.5.0 introduced a new config format with graceful default values, so check the new config file fritzbox_user.conf.php


### Basic usage advisory ####

The scripts are well documented, please take a look to understand them.
This is also the right moment to check the config file "fritzbox.conf.php"!

All files must be in the same directory. If this condition is fulfilled, you don't need to pay any more attention to "fritzbox_api.class.php".

To use "fritzbox_tam_on_off.php", you have to call it in a terminal, it will then explain its usage. This script is a reference implementation of the PHP Fritz!Box API, use it as a base for your own implementations



### Usage on a Windows system ###

The script works fine on my Windows 7 machine and a simply extraced PHP 5.3 distribution (get it at http://windows.php.net/download/, PHP 5.4 works as well). The cURL extension and the mbstring extenstion must be enabled in the php.ini and the correct timezone must be set. To do this, copy the php.ini-production to php.ini and uncomment/change the following directives:

extension_dir = "ext"
extension=php_curl.dll
extension=php_mbstring.dll
date.timezone = Europe/Berlin

After you have done that, you can call the script in a terminal:

C:\>"path\to\php.exe" "path\to\fritzbox_tam_on_off.php"

i.e. if you extracted PHP to c:\php and the Fritz!Box PHP API to a subfolder named fritz_api, you call it this way:
C:\>cd php
C:\php>"php.exe" "fritz_api\fritzbox_tam_on_off.php"

If you use the Windows taskplanner, configure the logger to a logfile or to silent mode and call via php-win.exe instead of php.exe. This will prevent the terminal from being opened.



### Usage on a UNIX system ###

If you use UNIX, you should be familiar with calling a PHP script via the PHP-CLI. If you don't have the PHP-CLI installed, you can edit the $argv part in "fritz_tam_on_off.php" to work with PHP-CGI and $_GET or you hardcode the necessary arguments.

Ensure that the cURL and the mbstring extensions are available and a valid timezone is set. The script was tested on a Ubuntu Server machine with PHP 5.3.



### Feedback, license, support ###
You are welcome to send me feedback via email (Gregor [at] der-meyer.de) or visit my personal blog at http://spackmat.de/spackblog (in German)

The whole work is licensed under a Creative Commons cc-by-sa license (http://creativecommons.org/licenses/by-sa/3.0/de/). You are free to use and modify it, even for commercial use. If you redistribute it, you have to ensure my name is kept in the code and you use the same conditions.

Feel free to add (and contribute) other nice scripts. The API class should work with any config item, which is available in the Fritz!Box Web UI. Use Firebug or LiveHeaders to figure out the name of the proper POST-Field.

I won't give any personal support for this script, unless you pay for it. :) I'm a freelance IT-consultant and webdeveloper, loocated in Düsseldorf, Germany.
Loading

0 comments on commit a1d667e

Please sign in to comment.