PHP code example of rypsx / infomaniak

1. Go to this page and download the library: Download rypsx/infomaniak library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rypsx / infomaniak example snippets



	use Rypsx\Infomaniak\Infomaniak;

	sername you are using on Infomaniak admin
     	* `passwd`  is the password you are using on Infomaniak admin
     	* `rate` 	 is the rate you want select. Eg : 128 / 96 / 64 or string like low / high, etc.
     	* `codec`   is the type of codec you want to select. Eg : mp3 / aac, etc.
     	* `sorted`  This parameter MUST be set to true or false. By setting true,
     	*           it allow you to sort current listener by decreasing playing time. DEFAULT FALSE
     	* `ipapi`   This parameter MUST be set to true or false. By setting true,
     	*           it allow you to get geographic informations about your listeners.
     	*           This API allows only 150 queries per minute, so a module is set up to prevent
     	*           any query exceeds the 150th. DEFAULT FALSE
     	*/
    

    	// Getting only Flux state, Live stats & current listeners informations
    	// $im = new Infomaniak(`login`, `passwd`, `128`, `mp3`);

    	// Getting all informations :: TYPICALLY EXAMPLE for version 3
    	$im = new Infomaniak(`login`, `passwd`, 128, `mp3`, true, true);
    
    	// Get info about geolocation of current listeners
    	/*
    	foreach ($im->current as $num => $current) {
        	var_dump($current->ipApi);
    	}
    	*/

	} catch (\Exception $e) {
	    print $e->getMessage();
	}

	var_dump($im);

object(Rypsx\Infomaniak\Infomaniak)[3]
  protected 'login' => string '****' (length=12)
  protected 'passwd' => string '****' (length=8)
  protected 'rate' => string '128' (length=3)
  protected 'codec' => string 'mp3' (length=3)
  public 'erreur' => null
  public 'updateDate' => string '2016-09-18 13:39:14' (length=19)
  public 'flux' => 
    object(Rypsx\Infomaniak\FluxState)[2]
      public 'principal' => string 'UP' (length=2)
      public 'backup' => string 'UP' (length=2)
  public 'live' => 
    object(Rypsx\Infomaniak\LiveStats)[5]
      public 'peak' => int 154
      public 'current' => int 6
  public 'current' => 
    array (size=6)
      27020 => 
        object(Rypsx\Infomaniak\CurrentListeners)[36]
          public 'ip' => string '****' (length=13)
          public 'dureeEcoute' => string '8 heures' (length=8)
          public 'ipApi' => 
            object(Rypsx\Ipapi\Ipapi)[34]
              public 'erreur' => null
              public 'date' => string '2016-09-18 13:39:40' (length=19)
              public 'ipAdr' => string '****' (length=13)
              public 'ip2long' => int ****
              public 'ipapi' => 
                object(Rypsx\Ipapi\IpRequest)[18]
                  public 'erreur' => 
                    array (size=0)
                      empty
                  public 'status' => string 'success' (length=7)
                  public 'pays' => string 'United States' (length=13)
                  public 'paysCode' => string 'US' (length=2)
                  public 'region' => string '****' (length=8)
                  public 'ville' => string '****' (length=7)
                  public 'cp' => string '****' (length=5)
                  public 'latitude' => string '****' (length=7)
                  public 'longitude' => string '****' (length=8)
                  public 'timezone' => string 'America/Chicago' (length=15)
                  public 'isp' => string '****' (length=13)
      8535 => 
        object(Rypsx\Infomaniak\CurrentListeners)[39]
          public 'ip' => string '****' (length=11)
          public 'dureeEcoute' => string '2 heures' (length=8)
          public 'ipApi' => 
            object(Rypsx\Ipapi\Ipapi)[37]
              public 'erreur' => null
              public 'date' => string '2016-09-18 13:39:40' (length=19)
              public 'ipAdr' => string '****' (length=11)
              public 'ip2long' => int ****
              public 'ipapi' => 
                object(Rypsx\Ipapi\IpRequest)[27]
                  public 'erreur' => 
                    array (size=0)
                      empty
                  public 'status' => string 'success' (length=7)
                  public 'pays' => string 'Germany' (length=7)
                  public 'paysCode' => string 'DE' (length=2)
                  public 'region' => string '****' (length=7)
                  public 'ville' => string '****' (length=9)
                  public 'cp' => string '' (length=0)
                  public 'latitude' => string '****' (length=6)
                  public 'longitude' => string '****' (length=7)
                  public 'timezone' => string 'Europe/Berlin' (length=13)
                  public 'isp' => string '****' (length=19)
      6914 => 
        object(Rypsx\Infomaniak\CurrentListeners)[30]
          public 'ip' => string '****' (length=11)
          public 'dureeEcoute' => string '2 heures' (length=8)
          public 'ipApi' => 
            object(Rypsx\Ipapi\Ipapi)[7]
              public 'erreur' => null
              public 'date' => string '2016-09-18 13:39:40' (length=19)
              public 'ipAdr' => string '****' (length=11)
              public 'ip2long' => int ****
              public 'ipapi' => 
                object(Rypsx\Ipapi\IpRequest)[21]
                  public 'erreur' => 
                    array (size=0)
                      empty
                  public 'status' => string 'success' (length=7)
                  public 'pays' => string 'France' (length=6)
                  public 'paysCode' => string 'FR' (length=2)
                  public 'region' => string '****' (length=17)
                  public 'ville' => string '****' (length=17)
                  public 'cp' => string '****' (length=5)
                  public 'latitude' => string '****' (length=7)
                  public 'longitude' => string '****' (length=7)
                  public 'timezone' => string 'Europe/Paris' (length=12)
                  public 'isp' => string '****' (length=3)
      4605 => 
        object(Rypsx\Infomaniak\CurrentListeners)[42]
          public 'ip' => string '****' (length=13)
          public 'dureeEcoute' => string '1 heure' (length=7)
          public 'ipApi' => 
            object(Rypsx\Ipapi\Ipapi)[40]
              public 'erreur' => null
              public 'date' => string '2016-09-18 13:39:40' (length=19)
              public 'ipAdr' => string '****' (length=13)
              public 'ip2long' => int ****
              public 'ipapi' => 
                object(Rypsx\Ipapi\IpRequest)[12]
                  public 'erreur' => 
                    array (size=0)
                      empty
                  public 'status' => string 'success' (length=7)
                  public 'pays' => string 'France' (length=6)
                  public 'paysCode' => string 'FR' (length=2)
                  public 'region' => string '****' (length=14)
                  public 'ville' => string '****' (length=5)
                  public 'cp' => string '****' (length=5)
                  public 'latitude' => string '****' (length=7)
                  public 'longitude' => string '****' (length=6)
                  public 'timezone' => string 'Europe/Paris' (length=12)
                  public 'isp' => string '****' (length=6)
      2105 => 
        object(Rypsx\Infomaniak\CurrentListeners)[10]
          public 'ip' => string '****' (length=13)
          public 'dureeEcoute' => string '35 min' (length=6)
          public 'ipApi' => 
            object(Rypsx\Ipapi\Ipapi)[4]
              public 'erreur' => null
              public 'date' => string '2016-09-18 13:39:40' (length=19)
              public 'ipAdr' => string '****' (length=13)
              public 'ip2long' => int ****
              public 'ipapi' => 
                object(Rypsx\Ipapi\IpRequest)[11]
                  public 'erreur' => 
                    array (size=0)
                      empty
                  public 'status' => string 'success' (length=7)
                  public 'pays' => string 'France' (length=6)
                  public 'paysCode' => string 'FR' (length=2)
                  public 'region' => string '****' (length=17)
                  public 'ville' => string '****' (length=9)
                  public 'cp' => string '****' (length=5)
                  public 'latitude' => string '****' (length=7)
                  public 'longitude' => string '****' (length=7)
                  public 'timezone' => string 'Europe/Paris' (length=12)
                  public 'isp' => string '****' (length=8)
      467 => 
        object(Rypsx\Infomaniak\CurrentListeners)[33]
          public 'ip' => string '****' (length=13)
          public 'dureeEcoute' => string '8 min' (length=5)
          public 'ipApi' => 
            object(Rypsx\Ipapi\Ipapi)[31]
              public 'erreur' => null
              public 'date' => string '2016-09-18 13:39:40' (length=19)
              public 'ipAdr' => string '****' (length=13)
              public 'ip2long' => int ****
              public 'ipapi' => 
                object(Rypsx\Ipapi\IpRequest)[15]
                  public 'erreur' => 
                    array (size=0)
                      empty
                  public 'status' => string 'success' (length=7)
                  public 'pays' => string 'France' (length=6)
                  public 'paysCode' => string 'FR' (length=2)
                  public 'region' => string '****' (length=14)
                  public 'ville' => string '****' (length=26)
                  public 'cp' => string '****' (length=5)
                  public 'latitude' => string '****' (length=7)
                  public 'longitude' => string '****' (length=6)
                  public 'timezone' => string 'Europe/Paris' (length=12)
                  public 'isp' => string '****' (length=8)
  private 'counterIpApi' => int 6