Documentation
WEBAPI
usage
<WEBAPI ID="number">
<INFO>
<ID>number</ID>
<ACTIVITY>1</ACTIVITY>
<ISLOCKED>0</ISLOCKED>
<CREATORID>contactID</CREATORID>
<OWNERID>contactID</OWNERID>
<GROUPID>groupID</GROUPID>
<MODIFIERID>contactID</MODIFIERID>
<CREATIONDATE>YYYY-MM-DD hh:mm:ss</CREATIONDATE><!-- automatically filled by Sushee -->
<MODIFICATIONDATE>YYYY-MM-DD hh:mm:ss</MODIFICATIONDATE><!-- automatically filled by Sushee -->
<DENOMINATION>text</DENOMINATION>
<CLASSFILE>text</CLASSFILE>
<CLASSNAME>text</CLASSNAME>
</INFO>
</WEBAPI>
paramètres
DENOMINATION: the name of the API (Dropbox, Twitter and LinkedIn are already implemented).
CLASSFILE: the path to the file implementing the API
CLASSNAME: the name of the class implementing the API
Describes a webservice which possesses a json or XML API.
The webservice methods should be implemented in a separate PHP file. You can take as a starting point the webaccount/apis/api_example.class.php file included in sushee.
The API is defined as a PHP class extending the Sushee_OAuthWebAccount interface. It must be registered in xsushee (CREATE) to be recognized.
Every method that will be used in xsushee must start with an underscore.
When the API is defined with its methods, you have to create a webaccount of this type and call its methods using the <CALL><WEBACCOUNT> command. The only argument of the method is the node inside the <CALL><WEBACCOUNT>.
exemples
<CREATE>
<WEBAPI>
<INFO>
<DENOMINATION>MyTwitterExtension</DENOMINATION>
<CLASSFILE>/public/mytwitter.class.php</CLASSFILE>
<CLASSNAME>MyTwitterAPI</CLASSNAME>
</INFO>
</WEBAPI>
</CREATE>
<?php
class MyTwitterAPI extends Sushee_OAuthWebaccount{
var $consumerKey = 'q7Llo0Qvf2wXyGTiZUEvSA';
var $consumerSecret = 'org5nLgFFGoE2p9GGWCAnKTAXeUWkoEvy5MAQoZqRc';
var $requestTokenURL = 'https://api.twitter.com/oauth/request_token';
var $accessTokenURL = 'https://api.twitter.com/oauth/access_token';
var $authorizeURL = 'https://api.twitter.com/oauth/authorize';
//--------------
// API methods
//--------------
function _postMessage(/* XMLNode */ $node){
$text = $node->valueOf('TEXT');
$this->setURL('https://api.twitter.com/1/statuses/update.xml');
$this->setMethod('post');
$this->addParam('status','My twitter : '.decode_from_xml($text));
$response = $this->request();
return $response;
}
}
<CREATE>
<WEBACCOUNT>
<INFO>
<DENOMINATION>My twitter account</DENOMINATION>
<API>MyTwitterExtension</API>
</INFO>
</WEBACCOUNT>
</CREATE>
<AUTHORIZE>
<WEBACCOUNT ID="3"></WEBACCOUNT>
</AUTHORIZE>
<CALL>
<WEBACCOUNT ID="3">
<POSTMESSAGE>
<TEXT>Hello twitter!</TEXT>
</POSTMESSAGE>
</WEBACCOUNT>
</CALL>
Voir aussi :
WEBACCOUNT
Describes an access to a distant WebAPI (Twitter, Dropbox, LinkedIn)
AUTHORIZE WEBACCOUNT
Starts the process to get an oauth access to a distant webservice
CALL WEBACCOUNT
Calls a webservice method