1
wishcraft
XIPS - Protocol Planning (Discovery) - HTML Headers

The XIPS Protocol will be used for exchanging social networking information between friendica instances, this is through the use of CURL and a method very similar to oAuth but called XIPSNetworkAuth for a handshake method.

IN xfriendica the Protocol files for XIPS will have a preloader which calls on the following function via magic functions and send header information before the buffer is sent, now there is a little bit more to this routine than I have shown, it also has to recieve the header information of the request incase it is a private not a publci network and to see if they have the right secret to be accepted.. Anyway so via magic functions the following is found in the Protocols preloads sections:

/**
 * Xfriendica Protocol XIPS Example Preloads
 */
class ProtocolXIPSPreload extends FriendicaPreloadItem {
    
    function 
eventCoreHeaderStart($args)    
    {
        
// Core Settings on XIPS Header Data
        // module name
        
header('XIPS-Instance-Network-Name: XFriendica');
        
// site name
        
header('XIPS-Instance-Network-Site: XOOPS Site');
        
// global identify guid for this instance
        
header('XIPS-Identity-Network-GUID: sdjkrfy834756346o52h64o3r87267ho3468o234dgbodg56g');
        
// your handshake for this instance
        
header('XIPS-Handshake-Network-Key: sdlfku489ujf984v5ghijrehg89067ho3468o234dgbodg56g');
        
// your handshake method for this instance
        
header('XIPS-Handshake-Network-Method: XIPSNetworkAuth');
        
// your Network Acceptance Type for this instance can be: accepted, added, not accepting, requires secret
        
header('XIPS-Instance-Network-Acceptance: accepted');
        
// (Optional) your Network Secret for this instance is only required when it is a private network 
        // and Network-Acceptance = requires secret
        
header('XIPS-Instance-Network-Secret: 84v5ghi8o234dgbojrehg89067ho346sdlfku489ujf9dg56g');
        
// URL for Root of Site
        
header('XIPS-Instance-Network-URL: '.XOOPS_URL);
        
// Version of XFriendica Engine
        
header('XIPS-Instance-Engine-Version: 1.2.3');
        
// Version of XFriendica XIPS Protocol Engine
        
header('XIPS-Protocol-Engine-Version: 1.2.3');
        
// Version of XFriendica XIPS Services Engine
        
header('XIPS-Services-Engine-Version: 1.2.3');
        
// Version of XFriendica XIPS User API Engine
        
header('XIPS-API-Engine-Version: 1.2.3');
        
// Version of XFriendica XIPS Push Engine
        
header('XIPS-Push-Engine-Version: 1.2.3');
        
// Version of XFriendica XIPS Pull Engine
        
header('XIPS-Pull-Engine-Version: 1.2.3');
        
// GMT of Instance
        
header('XIPS-Instance-Network-GMT: 10.00+');
        
// Time of Day Services and API is Open Seconds of Day ie 0 = 0:0:0
        
header('XIPS-Instance-Network-Opens: 0');
        
// Time of Day Services and API is Open Seconds of Day ie. 86399 = 23:59:59
        
header('XIPS-Instance-Network-Closes: 86399');
        
// Time when system came online last
        
header('XIPS-Instance-Network-Online: 138736423');
        
// Number of Seconds to Wait between Polling Function (Otherwise presented 404)
        
header('XIPS-Instance-Interval-Poll: 5');
        
// Number of Seconds to Wait between Pushing a Function (Otherwise presented 404)
        
header('XIPS-Instance-Interval-Push: 5');
        
// (Optional) When the API & Services are Offline till by Server Time
        
header('XIPS-Instance-Network-Offline: 138736423');
        
        
        
// API Settings on XIPS Header Data
        // API Location
        
header('XIPS-API-User-Location: /modules/friendica/api/');
        
// Methods available on API
        
header('XIPS-API-User-Methods: json,serial,xml,soap');
        
// List of API Functions
        
header('XIPS-API-User-Functions: /modules/friendica/api/functions/');
        
// Authentication Method on API (REST String to provide)
        
header('XIPS-API-User-Authentication: username=%email%&password=%password%');
        
// Method of Password Passing can be md5, sha1 or open
        
header('XIPS-API-Password-Method: md5');
        
        
// Services Settings on XIPS Header Data
        // Number of Protocols available for download and use on Services
        
header('XIPS-Services-Numberof-Protocols: 4');
        
// Number of Addons available for download and use on Services
        
header('XIPS-Services-Numberof-Addons: 3');
        
// Number of Plugins available for download and use on Services
        
header('XIPS-Services-Numberof-Plugins: 5');
        
// Number of Addons available for download and use on Services
        
header('XIPS-Services-Numberof-Adaptors: 3');
        
// Number of Plugins available for download and use on Services
        
header('XIPS-Services-Numberof-Connectors: 5');
        
// Number of Plugins available for download and use on Services
        
header('XIPS-Services-Numberof-Resources: 0');
        
// Methods available on Services
        
header('XIPS-Services-API-Methods: json,serial,xml,soap');
        
// Methods available on Services
        
header('XIPS-Services-API-Types: Protocols=protocol,Addons=addon,Plugins=plugin,Adaptors=adaptor,Connectors=connector,Resources=resource');
        
// URI for Services API for Resources
        
header('XIPS-Plugins-Resources-Location: /modules/friendica/services/resources/');
        
// URI for List of Functions on Services API for Resources
        
header('XIPS-Plugins-Resources-Functions: /modules/friendica/services/resources/functions/');
        
// URI for List of Resources available on Services API for Downloading
        
header('XIPS-Plugins-Resources-List: /modules/friendica/services/resources/available/');
        
// URI for Services API for Plugins
        
header('XIPS-Plugins-Services-Location: /modules/friendica/services/plugins/');
        
// URI for List of Functions on Services API for Plugins
        
header('XIPS-Plugins-Services-Functions: /modules/friendica/services/plugins/functions/');
        
// URI for List of Plugins available on Services API for Downloading
        
header('XIPS-Plugins-Services-List: /modules/friendica/services/plugins/available/');
        
// URI for Services API for Addons
        
header('XIPS-Addons-Services-Location: /modules/friendica/services/addons/');
        
// URI for List of Functions on Services API for Addons
        
header('XIPS-Addons-Services-Functions: /modules/friendica/services/addons/functions/');
        
// URI for List of Addons available on Services API for Downloading
        
header('XIPS-Addons-Services-List: /modules/friendica/services/addons/available/');
        
// URI for Services API for Adaptors
        
header('XIPS-Adaptors-Services-Location: /modules/friendica/services/adaptors/');
        
// URI for List of Functions on Services API for Adaptors
        
header('XIPS-Adaptors-Services-Functions: /modules/friendica/services/adaptors/functions/');
        
// URI for List of Adaptors available on Services API for Downloading
        
header('XIPS-Adaptors-Services-List: /modules/friendica/services/adaptors/available/');
        
// URI for Services API for Connectors
        
header('XIPS-Connectors-Services-Location: /modules/friendica/services/connectors/');
        
// URI for List of Functions on Services API for Connectors
        
header('XIPS-Connectors-Services-Functions: /modules/friendica/services/connectors/functions/');
        
// URI for List of Connectors available on Services API for Downloading
        
header('XIPS-Connectors-Services-List: /modules/friendica/services/connectors/available/');
        
// URI for Services API for Protocols
        
header('XIPS-Protocols-Services-Location: /modules/friendica/services/protocols/');
        
// URI for List of Functions on Services API for Protocols
        
header('XIPS-Protocols-Services-Functions: /modules/friendica/services/protocols/functions/');
        
// URI for List of Protocols available on Services API for Downloading
        
header('XIPS-Protocols-Services-List: /modules/friendica/services/protocols/available/');
        
// URI for Services API for Pushing Data
        
header('XIPS-Push-Services-Location: /modules/friendica/services/push/');
        
// URI for List of Functions on Services API for Pushing Data
        
header('XIPS-Push-Services-Functions: /modules/friendica/services/push/functions/');
        
// URI for Services API for Poll
        
header('XIPS-Poll-Services-Location: /modules/friendica/services/poll/');
        
// URI for List of Functions on Services API for Poll
        
header('XIPS-Poll-Services-Functions: /modules/friendica/services/poll/functions/');    
    }
}


So this means there will always be a series of headers set when the /header.php is loaded or even in the system, this contains authentication information if they are authenticating with the service, and will check for public details or private network secrets and only authenticate and populate the friendica_networks_* tables when it is authorised on the services API.

So how would you query this well you could hit the root of the site like index.php with the following similar cURL code:

function curl_parse $response )
{
    if (empty(
$response))
    {
        return array();
    }

    @list(
$headers,$body) = explode("rnrn",$response,2);
    
$lines explode("rn",$headers);

    if (
preg_match('@^HTTP/[0-9].[0-9] +100@'$lines[0]))
    {
        
/* HTTP/1.x 100 Continue
         * the real data is on the next line
        */
        
@list($headers,$body) = explode("rnrn",$body,2);
        
$lines explode("rn",$headers);
    }

    
// first line of headers is the HTTP response code
    
$http_line array_shift($lines);
    if (
preg_match('@^HTTP/[0-9].[0-9] +([0-9]{3})@'$http_line$matches))
    {
        
$code $matches[1];
    }

    
// put the rest of the headers in an array
    
$headers = array();
    foreach (
$lines as $l)
    {
        list(
$k$v) = explode(': '$l2);
        
$headers[strtolower($k)] = $v;
    }

    return array( 
'code' => $code'headers' => $headers'body' => $body);
}

$header[]         = 'Content-Type: application/octet-stream';
$header[]         = 'XIPS-Interface-Network-GUID: 348906u8hgdfog890403hy9gfduivhopdzt348g99p80j';
// Required when Intialising with a Private Network You need the Network Secret for your service
  
$header[]         = 'XIPS-Interface-Network-Secret: wty8ufn5789wch87h87w54h8c785u4hg8uwh84th659';
  
$header[]         = 'XIPS-Interface-Network-Callback: http://mysite.com/modules/friendica/services/callback'
  
$header[]         = 'XIPS-Interface-Handshake-Method: XIPSAuth';

curl_setopt($chCURLOPT_HTTPHEADER,         $header);
curl_setopt($chCURLOPT_USERAGENT,             'XFriendica 1.2.3/XIPS Discovery (XIPS 1.0.1, PHP '.PHP_VERSION.', '.XOOPS_VERSION.')');
curl_setopt($chCURLOPT_URL,                  $url);
curl_setopt($chCURLOPT_RETURNTRANSFER,     true);
curl_setopt($chCURLOPT_HEADER,              true);
curl_setopt($chCURLOPT_SSL_VERIFYPEER,     false);
curl_setopt($chCURLOPT_VERBOSE,             false);
curl_setopt($chCURLOPT_TIMEOUT,              45);
curl_setopt($chCURLOPT_CONNECTTIMEOUT,     45);
$data curl_parse(curl_exec($ch));
curl_close($ch);

// $data['header'] contains the following information retrieved from the service

// XIPS-Instance-Network-Name: XFriendica
// XIPS-Instance-Network-Site: XOOPS Site
// XIPS-Identity-Network-GUID: sdjkrfy834756346o52h64o3r87267ho3468o234dgbodg56g
// XIPS-Handshake-Network-Key: sdlfku489ujf984v5ghijrehg89067ho3468o234dgbodg56g
// XIPS-Handshake-Network-Method: HeaderAsXIPS
// XIPS-Instance-Network-Acceptance: accepted
// XIPS-Instance-Network-Secret: 84v5ghi8o234dgbojrehg89067ho346sdlfku489ujf9dg56g
// XIPS-Instance-Network-URL: http://xfriendica.com
// XIPS-Instance-Engine-Version: 1.2.3
// XIPS-Protocol-Engine-Version: 1.2.3
// XIPS-Services-Engine-Version: 1.2.3
// XIPS-API-Engine-Version: 1.2.3
// XIPS-Push-Engine-Version: 1.2.3
// XIPS-Pull-Engine-Version: 1.2.3
// XIPS-Instance-Network-GMT: 10.00+
// XIPS-Instance-Network-Opens: 0
// XIPS-Instance-Network-Closes: 86399
// XIPS-Instance-Network-Online: 138736423
// XIPS-Instance-Interval-Poll: 5
// XIPS-Instance-Interval-Push: 5
// XIPS-Instance-Network-Offline: 138736423
// XIPS-API-User-Location: /modules/friendica/api/
// XIPS-API-User-Methods: json,serial,xml,soap
// XIPS-API-User-Functions: /modules/friendica/api/functions/
// XIPS-API-User-Authentication: username=%email%&password=%password%
// XIPS-API-Password-Method: md5
// XIPS-Services-Numberof-Protocols: 4
// XIPS-Services-Numberof-Addons: 3
// XIPS-Services-Numberof-Plugins: 5
// XIPS-Services-Numberof-Adaptors: 3
// XIPS-Services-Numberof-Connectors: 5
// XIPS-Services-Numberof-Resources: 0
// XIPS-Services-API-Methods: json,serial,xml,soap
// XIPS-Services-API-Types: Protocols=protocol,Addons=addon,Plugins=plugin,Adaptors=adaptor,Connectors=connector,Resources=resource
// XIPS-Plugins-Resources-Location: /modules/friendica/services/resources/
// XIPS-Plugins-Resources-Functions: /modules/friendica/services/resources/functions/
// XIPS-Plugins-Resources-List: /modules/friendica/services/resources/available/
// XIPS-Plugins-Services-Location: /modules/friendica/services/plugins/
// XIPS-Plugins-Services-Functions: /modules/friendica/services/plugins/functions/
// XIPS-Plugins-Services-List: /modules/friendica/services/plugins/available/
// XIPS-Addons-Services-Location: /modules/friendica/services/addons/
// XIPS-Addons-Services-Functions: /modules/friendica/services/addons/functions/
// XIPS-Addons-Services-List: /modules/friendica/services/addons/available/
// XIPS-Adaptors-Services-Location: /modules/friendica/services/adaptors/
// XIPS-Adaptors-Services-Functions: /modules/friendica/services/adaptors/functions/
// XIPS-Adaptors-Services-List: /modules/friendica/services/adaptors/available/
// XIPS-Connectors-Services-Location: /modules/friendica/services/connectors/
// XIPS-Connectors-Services-Functions: /modules/friendica/services/connectors/functions/
// XIPS-Connectors-Services-List: /modules/friendica/services/connectors/available/
// XIPS-Protocols-Services-Location: /modules/friendica/services/protocols/
// XIPS-Protocols-Services-Functions: /modules/friendica/services/protocols/functions/
// XIPS-Protocols-Services-List: /modules/friendica/services/protocols/available/
// XIPS-Push-Services-Location: /modules/friendica/services/push/
// XIPS-Push-Services-Functions: /modules/friendica/services/push/functions/
// XIPS-Poll-Services-Location: /modules/friendica/services/poll/
// XIPS-Poll-Services-Functions: /modules/friendica/services/poll/functions/
//

Login

Who's Online

199 user(s) are online (126 user(s) are browsing Support Forums)


Members: 0


Guests: 199


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Mar 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits