Menu

YfiDevelopThirdParty

Anonymous

Background

  • It is sometimes required for one system to talk with another system.
  • YFi Hotspot Manager includes such functionality.
  • As from Beta-4 you can now with a simple http get command generate vouchers.
  • This makes it easy for any 3rd Party System to create a voucher.
  • Payment or Hotel booking systems can simply issue a http get command once a transaction is completed to acquire a voucher for a person.
  • This voucher's detail can then be forwarded to the person by various means including a web page, SMS, e-mail etc.

Steps to active third party integration

  • Create an Access Provider which will be specified as the creator of vouchers generated by 3rd Party Systems. (we use 3rd_sms)
  • Decide on a shared secret between the YFi Hotspot Manager system and the third party system. (we use 123456789)
  • Determine the IP from which the request will come in (we use 127.0.0.1)
  • Edit the /var/www/c2/yfi_cake/controllers/third_parties_controller.php file to reflect the above choices

    //___ Some required values -> Change to suit your setup ____
    $key_master     = '123456789';
    $access_provider= '3rd_sms';    //The name of the Access Provider that this will be made the creator of
    //Added Security!
    $request_from   = $_SERVER["REMOTE_ADDR"];      //Only allow request to come from specified server
    if($request_from != '127.0.0.1'){
        $this->set('json_return',$this->Json->permFail());
        return;
    }
    //__________________________________________________________
    
  • Call the controller method from your browser with the all the required key/value pairs

http://127.0.0.1/c2/yfi_cake/third_parties/json_create_voucher/?key=123456789&voucher_value=1-00-00-00&profile=Voucher+10M+CAP&expires=2010-07-01&precede=sms&realm=Residence+Inn


Required values

Key
Typical Value

key
123456789

voucher_value
1-00-00-00

profile
Voucher 10M CAP

expires
2010-07-01

precede
sms

realm
Residence Inn

Sample PHP page

  • You can also navigate to the following page and click on the Create Voucher button.
    http://127.0.0.1/yfi/voucher_third_party_poc.php
  • This will use php to call the wget program with the url that is used to generate vouchers. The feedback from wget is then sanitized a bit in order for the json_decode function to return it as an array.
  • This array's values can then be used as you please - in this sample we simply display it on the web page.
  • Note the above page can be used as a guideline for your own special implementation which integrates with a third party system.

Creating Permanent users

  • As from SVN 424 one can also create permanent users through the 3rd party web service.

Required values

Key
_Typical Value__ _

key
123456789

username
koos

password
koos

realm
Residence Inn

profile
Permanent 250M CAP

cap
hard

Sample call

http://127.0.0.1/c2/yfi_cake/third_parties/json_create_permanent/?key=123456789&callback=completed&username=koosie&password=koos&profile=Permanent+250M+CAP&realm=Residence+Inn&cap=hard

Sample Feedback

completed(
    {"json"    : {"status":"ok"},
     "user"    : { "user_id":"4b69399f-aa58-4f3b-8015-4858a509ff00",
                   "access_provider":"3rd_sms",
                   "profile_id":"4a62f9c4-25a8-45bc-ab56-1c84a509ff00",
                   "profile_name":"Permanent 250M CAP",
                   "realm_id":"49d09ec6-5480-45d4-a5ae-2b0ea509ff00",
                   "realm_name":"ri",
                   "username":"koosie",
                   "password":"koos",
                   "cap":"hard"}
    }
);

Still outstanding

  • A 3rd Party way to create credits for permanent users and assign it to their names.

Sample SQL structure

  • Below is a sample SQL dump which can be used for testing purposes. It already contains the required Access Provider.

Related

Wiki: Home