XT Knowledge Base
Hauptseite | Über | Hilfe | FAQ | Spezialseiten | Anmelden

Druckversion | Impressum | Datenschutz | Aktuelle Version

Tiffu Beschreibung

(Unterschied zwischen Versionen)

K (API)
(API)
 
(Der Versionsvergleich bezieht 1 dazwischenliegende Version mit ein.)
Zeile 6: Zeile 6:
Beispiel:
Beispiel:
<pre>
<pre>
 +
&lt;?
     include( "../cfg.php" );
     include( "../cfg.php" );
     include( "../mysqldb.php" );
     include( "../mysqldb.php" );
     include( "tiffuapi.php" );
     include( "tiffuapi.php" );
-
       
+
 
-
     define( 'MAN_UPD_ALL',          'af6f3fa8682bc984d73c5edc0e39b162' );
+
     $tiffu_user = 'tiffu';
-
     define( 'MAN_UPD_YESTERDAY',    'aada7cee2dbfe6893e3dbdb29c10db45' );
+
     $tiffu_password = '*****';
-
     define( 'MAN_UPD_TODAY',        'f44b4df415ba75eb2aa760d6d069ab7a' );
+
      
-
     define( 'STATES_PUBLIC',        'f2a223aedca3bbbd6e2552477dfa9007' );
+
     // API-Key für die zu beschreibende Variable
-
    define( 'STATES_ALL',          '5bde43a643a43448049500a2b71cd17b' );
+
     define( 'REG_USER', 'ba7c61f9099a19234b2c5db969fddd02' );
-
     define( 'REG_USER',             'ba7c61f9099a19234b2c5db969fddd02' );
+
-
    define( 'FRESH_USER',          '827d52af2c2c38c8a91aa7480a263ed4' );
+
     $db = new MySQLDB( $_CFG['DB_HOST'], $_CFG['DB_NAME'], $_CFG['DB_USER'], $_CFG['DB_PASS'] );
     $db = new MySQLDB( $_CFG['DB_HOST'], $_CFG['DB_NAME'], $_CFG['DB_USER'], $_CFG['DB_PASS'] );
-
     $request = new TiffuAPI( 'tiffu', '******' );
+
     $request = new TiffuAPI( $tiffu_user, $tiffu_password );
      
      
     function getCount( $sqlcmd )
     function getCount( $sqlcmd )
Zeile 38: Zeile 37:
      
      
     $reg_user = getCount( "select count(*) from state_user" );
     $reg_user = getCount( "select count(*) from state_user" );
-
    $states_all = getCount( "select count(*) from state_info" );
 
-
    $states_public = getCount( "select count(*) from state_info where state_privacy=0" );
 
-
    $man_upd_all = getCount( "select count(*) from state_log" );
 
-
    $man_upd_today = getCount( "select count(*) from state_log where log_time > substr( NOW(), 1, 10)" );
 
-
    $fresh_user = getCount( "select user_nick from state_user order by user_id desc limit 0,1" );
 
      
      
     echo "reg_user: $reg_user&lt;br&gt;\n";
     echo "reg_user: $reg_user&lt;br&gt;\n";
     updateVar( REG_USER, $reg_user );
     updateVar( REG_USER, $reg_user );
-
 
+
?&gt;
-
    echo "states_all: $states_all&lt;br&gt;\n";
+
-
    updateVar( STATES_ALL, $states_all );
+
-
 
+
-
    echo "states_public: $states_public&lt;br&gt;\n";
+
-
    updateVar( STATES_PUBLIC, $states_public );
+
-
 
+
-
    echo "man_upd_all: $man_upd_all&lt;br&gt;\n";
+
-
    updateVar( MAN_UPD_ALL, $man_upd_all );
+
-
 
+
-
    echo "man_upd_today: $man_upd_today&lt;br&gt;\n";
+
-
    updateVar( MAN_UPD_TODAY, $man_upd_today );
+
-
 
+
-
    echo "fresh_user: $fresh_user&lt;br&gt;\n";
+
-
    updateVar( FRESH_USER, $fresh_user );
+
</pre>
</pre>

Aktuelle Version vom 08:30, 10. Aug. 2010

Tiffu.com

...

API

Beispiel:

<?
    include( "../cfg.php" );
    include( "../mysqldb.php" );
    include( "tiffuapi.php" );

    $tiffu_user = 'tiffu';
    $tiffu_password = '*****';
    
    // API-Key für die zu beschreibende Variable
    define( 'REG_USER', 'ba7c61f9099a19234b2c5db969fddd02' );

    $db = new MySQLDB( $_CFG['DB_HOST'], $_CFG['DB_NAME'], $_CFG['DB_USER'], $_CFG['DB_PASS'] );
    $request = new TiffuAPI( $tiffu_user, $tiffu_password );
    
    function getCount( $sqlcmd )
    {
        global $db;
        $query = $db->query( $sqlcmd );
        return $query->getFirstField();        
    }
    
    function updateVar( $key, $value )
    {
        global $request;
        if( !$request->setVar( $key, $value ) )
            echo $request->getError()."<br>\n";
        else
            echo "success<br>\n";
    }    
    
    $reg_user = getCount( "select count(*) from state_user" );
    
    echo "reg_user: $reg_user<br>\n";
    updateVar( REG_USER, $reg_user );
?>