HaystackWebServiceClient Class Reference

List of all members.

Public Member Functions

 HaystackWebServiceClient ($authToken=null, $userId=null)
 ErrorCode ()
 Return the error code from the last command issued.
ErrorMsg ()
 Return the error message from the last command issued.
 HaystackCreate ($haystackName, &$retId, $membershipType= 'Basic', $admin=null, $adminPass=null)
 Create a new haystack.
 HaystackCategories ($hid, &$result, $subCmd= 'list', $categories=null, $limit=null)
 A method to manipulate the tag categories.
 HaystackDelete ($haystackId, $haystackName=null)
 Delete a haystack.
 HaystackId ($haystackName, &$retId)
 Issues the 'haystack_id command'.
 HaystackListProfiles ($haystackId, &$result, $category=null, $tag=null, $onlyVisible=null, $keywords=null, $limit=null)
 Lists all profiles within a haystack.
 HaystackSettings ($haystackId, &$response, $settings=array())
 Sets or Retrieves the settings of a haystack.
 HaystackTags ($hid, &$result, $subCmd= 'list', $category= 'Organization', $tags=null, $profiles=null, $limit=null)
 Create/View/Delete the tags in a particular haystack.
 HtmlLastResponse ()
 FillStandardData (&$xmlParser)
LastResponse ()
 Return the last response from the web service. The response in in text format.
 MyNetworkAdd ($toUser, $whichUser)
 Adds a profile to a another profile network of users.
 MyNetworkDel ($fromProfile, $profile)
 Removes a profile from another profile network of users.
 MyNetworkList ($profile, &$result, $direction=0, $keywords=null, $limit=null)
 Lists all profiles which are in a give profile network.
 ProfileCreate ($hid, $profileEmail, $profilePass, $extraData=array())
 Create a new profile in a haystack or add existing profile to a haystack.
 ProfileDelete ($hid, $profileEmail)
 Delete a profile.
 ProfileInfo ($profileEmail, &$result, $keywords= '', $hid=null)
 Retrieve info about a particular profile.
 ProfileModify ($profileEmail, $extraData=array())
 Modify an existing profile in a haystack.
 SetBooleanResult ($booleanResult)
 A method to modify the $this->booleanResult member variable.
 ResponseTime ()

Public Attributes

 $wsaHost = 'haystack.speev.com'
 $wsaPort = '8080'
 The port to which to connect. The stndart port is 80.
 $wsaPath = '/rest/webcmd.php'
 The web page which will server your requests. Leave it as it is.
 $authToken = 'myAuthToken'
 Put here the authentication token you have received from Cerado.
 $userId = 'email@mysite.com'
 Put here the e-mail that you have entered when applying for 'authentication' token.
 $booleanResult = true
 Wheter or not to return boolean values as a result of the method calls.
 $lastResponse
 This variable will hold the last returned response XML data.
 $errorCode
 Will always hold the last error code.
 $errorMsg
 Will always hold the last error description string.
 $responseTime

Private Member Functions

 ProfileInfo_ParseProfile (&$parsedXml, &$result)
 RetValue ()
Request (&$parameters)
 A method to send a POST request to haystack.cerado.com and gather the returned result. Used by all other methods.
 XmlTheError ($errCode, $errMsg)

Detailed Description

The HaystackWebServiceClient is a class which was designed to hide from the end-user the burder to build its own communication library. It presents the Haytack Web Service API in the form of convinient method calls. All calls are synchronious. The results (where results are returned) are not in XML text but in convinient (for PHP) data structures.

If you do not like the format of the returned data, please feel free to modify each and every of the commands to suite your liking and purpose.


Member Function Documentation

HaystackWebServiceClient::ErrorCode (  ) 

Return the error code from the last command issued.

& HaystackWebServiceClient::ErrorMsg (  ) 

Return the error message from the last command issued.

HaystackWebServiceClient::FillStandardData ( &$  xmlParser  ) 

HaystackWebServiceClient::HaystackCategories ( hid,
&$  result,
subCmd = 'list',
categories = null,
limit = null 
)

A method to manipulate the tag categories.

Parameters:
[in] $hid The id of the haystack to manipulate.
[out] $result This is where the result is returned. Youc an safetly use the returned value only of the $subCmd parameter below is 'list'. In this case the $result will hold an array with all categories.
[in] $subCmd What to do with the categories. Can be one of the following 'list', 'add' and 'del'
[in] $categories This parameter specifies the name of the category to add or del. If can be a single category name e.g.: Misic or it can be an array of names: array('Music', 'Computers'). You can skip it if you only want to list all categories.
[in] $limit This one is a string in the form: 'X,Y'. It is optional. Also in the string format you can skip the X value. It will loke like this: 'Y'.

HaystackWebServiceClient::HaystackCreate ( haystackName,
&$  retId,
membershipType = 'Basic',
admin = null,
adminPass = null 
)

Create a new haystack.

Parameters:
[in] $haystackName The name of the new haystack.
[out] $retId The ID of the created haystack.
$membershipType The initial membership type of the haystack. Can be Basic or Express
[in] $admin The e-mail of the administrator. Can be skipped.
[in] $adminPass Password for the administrator. Should give it only if the $admin param is not skipped.

HaystackWebServiceClient::HaystackDelete ( haystackId,
haystackName = null 
)

Delete a haystack.

Parameters:
[in] $haystackId The ID of the haystack to be deleted.
[in] $haystackName The name of the haystack to be deleted. You can use it if you do not know the haystack id. Note that in order to use the name you need to pass -1 as $haystackId parameter.

HaystackWebServiceClient::HaystackId ( haystackName,
&$  retId 
)

Issues the 'haystack_id command'.

Parameters:
[in] $haystackName A string which specifies the haystack name we are interested in.
[out] $retId If the command is successful here is stored the returned haystack id.
Returns:
Depending on the $boolenaResult member variable this method will either return the error code of the operation or a boolean value indication success of failuer of the operation.

HaystackWebServiceClient::HaystackListProfiles ( haystackId,
&$  result,
category = null,
tag = null,
onlyVisible = null,
keywords = null,
limit = null 
)

Lists all profiles within a haystack.

Parameters:
[in] $haystackId The id of the haystack for which we would like to get profile list.
[out] $result The profiles are returned here as a result.
[in] $category If supplied, this parameter will force the system to return only those profiles which have tags under the specified category.
[in] $tag If supplied this parameter will force the system to return profiles which have entered the specified tag value. The category will not be taken into account if not explicitly specified by the $category parameter.
[in] $onlyVisible Should be 0 or 1.
[in] $keywords Specifies what specific information needs to be returned for the profiles.
[in] $limit Specifies the number of porfiles to return.

HaystackWebServiceClient::HaystackSettings ( haystackId,
&$  response,
settings = array() 
)

Sets or Retrieves the settings of a haystack.

Parameters:
[in] $haystackId The ID of the haystack.
[in] $response In this parameter you recevice the returned result. This will be an array where the key will be the tag(seting) name and the value will be the setting value.
[in] $settings This is an array of settings to set. The keys should be the settings names and the values should be the settings values. e.g.: array( 'private' => 1, 'dtag' => 'NewTag'). You can skip this parameter if you just want to retrieve the current settings.

HaystackWebServiceClient::HaystackTags ( hid,
&$  result,
subCmd = 'list',
category = 'Organization',
tags = null,
profiles = null,
limit = null 
)

Create/View/Delete the tags in a particular haystack.

Parameters:
[in] $hid The id of the haaystack which tags are about to be modified.
[out] $result In tihs parameter will be put the returned tag values of the $subCmd parameter is 'list'. Otherwize it will be empty.
[in] $subCmd The type of operation that can be performed over the tags. Can be one of the following strings:
  • list
  • add
  • del
[in] $category In haystack all tags are under some category. Here you specify the category name as string.
[in] $tags You should pass some value to this parameter only if you want to add or del tags.
[in] $profiles You should specify some value here only if you want to add or del profiles for a particular profile.
[in] $limit This parameter is used only when you are listing tags.

HaystackWebServiceClient::HaystackWebServiceClient ( authToken = null,
userId = null 
)

A constructor. You can pass him your auth token & user e-mail upon construction. Note that you can pass empty values here. In this case you would probably want to modify the $authToken & $userId member variables to match your security.

HaystackWebServiceClient::HtmlLastResponse (  ) 

& HaystackWebServiceClient::LastResponse (  ) 

Return the last response from the web service. The response in in text format.

HaystackWebServiceClient::MyNetworkAdd ( toUser,
whichUser 
)

Adds a profile to a another profile network of users.

Parameters:
[in] $toUser The profile which network to modify
[in] $whichUser The user which to add to $toUser network. Can be a list of comma separated e-mails.

HaystackWebServiceClient::MyNetworkDel ( fromProfile,
profile 
)

Removes a profile from another profile network of users.

Parameters:
[in] $fromProfile The profile from which to remove the other profile.
[in] $profile The profile which to remove from $fromProfile network. Can be a list of comma seprated e-mails.

HaystackWebServiceClient::MyNetworkList ( profile,
&$  result,
direction = 0,
keywords = null,
limit = null 
)

Lists all profiles which are in a give profile network.

Parameters:
[in] $profile The profile for who's network we request information.
[out] $result The result from the request is returned here. In order to figure out the result strucutre, please do a 'print_r' on it.
[in] $direction The type of information we require:
  • 0 - We request only people from the profile's network.
  • 1 - We request same information as with 0 but also request a list of profiles with have us, added in their network.
[in] $keywords What information to return for the profiles.
[in] $limit Specifies the number of porfiles to return.

HaystackWebServiceClient::ProfileCreate ( hid,
profileEmail,
profilePass,
extraData = array() 
)

Create a new profile in a haystack or add existing profile to a haystack.

Parameters:
[in] $hid The haystack to which to put the new profile. If the profile is newly created this haystack will become its main haystack.
[in] $profileEmail The e-mail (user id) of the new profile. Can be an e-mail of profile already existing in the system. In this case all other parameters are ignored.
[in] $profilePass The password for the profile. If an e-mail of existing profile was supplied, this parameter will be ignored.
[in] $extraData An array which can hold the rest of the parameters that can be passed to this command. e.g.: $usrInfo = array('fname' => 'Jim', 'lname' = 'Curton', 'location' => 'London, UK', 'bio' => 'A Cambridge Graduate');
So in general you will need to prepare such an array and pass it as a parameter to this method. Note that you do not need to specify all all parameters here but only those that you want to fill, in most cases this will be probably the fname and lname parameters.

HaystackWebServiceClient::ProfileDelete ( hid,
profileEmail 
)

Delete a profile.

Parameters:
[in] $hid The haystack from which to delete the profile.
[in] $profileEmail The e-mail of the profile to delete.

HaystackWebServiceClient::ProfileInfo ( profileEmail,
&$  result,
keywords = '',
hid = null 
)

Retrieve info about a particular profile.

Parameters:
[in] $profileEmail The e-mail of the profile we are interested in.
[out] $result The return data is put here.
[in] $keywords Some keywords to indicate what info we want to receive.
[in] $hid If you have put visible or admin in the $keywords parameter you need to pass a valid value for the $hid parameter. This must be a valid haystack id.

HaystackWebServiceClient::ProfileInfo_ParseProfile ( &$  parsedXml,
&$  result 
) [private]

HaystackWebServiceClient::ProfileModify ( profileEmail,
extraData = array() 
)

Modify an existing profile in a haystack.

Parameters:
[in] $profileEmail The e-mail (user id) of the profile.
[in] $extraData An array which can hold the rest of the parameters that can be passed to this command. e.g.: $usrInfo = array('fname' => 'Jim', 'lname' = 'Curton', 'location' => 'London, UK', 'bio' => 'A Cambrdige Graduate'); So in general you will need to prepare such an array and pass it as a parameter to this method. Note that you do not need to specify all all parameters here but only those that you want to fill, in most cases this will be probably the fname and lname parameters.
Remarks:
You should be aware that you might not be able to modify all of the profile's settings. If your haystack is the profile main haystack then you can modify all settings. Otherwize you will only be able to modify the 'visible' and 'admin' settings.

You should also know that the $extraData parameter is not checked for valid values. Unvalid parameters are simply ignored.

& HaystackWebServiceClient::Request ( &$  parameters  )  [private]

A method to send a POST request to haystack.cerado.com and gather the returned result. Used by all other methods.

HaystackWebServiceClient::ResponseTime (  ) 

HaystackWebServiceClient::RetValue (  )  [private]

Decides whether or not to return boolean or direct error code based on the $this->booleanResult variable.

HaystackWebServiceClient::SetBooleanResult ( booleanResult  ) 

A method to modify the $this->booleanResult member variable.

HaystackWebServiceClient::XmlTheError ( errCode,
errMsg 
) [private]


Member Data Documentation

HaystackWebServiceClient::$authToken = 'myAuthToken'

Put here the authentication token you have received from Cerado.

HaystackWebServiceClient::$booleanResult = true

Wheter or not to return boolean values as a result of the method calls.

All of the command methods are capable of returning two types of results: The first type of result is the error code of the operation. You need to compare it with HWSAPI_SUCCESS to know if the request was successful. In the second case, the methods do not return the error code but only true or false . Thus you can perform boolean checks if you find it more convinient.

HaystackWebServiceClient::$errorCode

Will always hold the last error code.

HaystackWebServiceClient::$errorMsg

Will always hold the last error description string.

HaystackWebServiceClient::$lastResponse

This variable will hold the last returned response XML data.

HaystackWebServiceClient::$responseTime

This will hold the time in milliseconds of the server to respond to our query. It does not contain the transfer & parsing time into it.

HaystackWebServiceClient::$userId = 'email@mysite.com'

Put here the e-mail that you have entered when applying for 'authentication' token.

HaystackWebServiceClient::$wsaHost = 'haystack.speev.com'

Here you should put the host to which to connect. In your case it should point to haystack.cerado.com. Please do not modify it.

HaystackWebServiceClient::$wsaPath = '/rest/webcmd.php'

The web page which will server your requests. Leave it as it is.

HaystackWebServiceClient::$wsaPort = '8080'

The port to which to connect. The stndart port is 80.


The documentation for this class was generated from the following file:
Generated on Fri Sep 15 14:08:26 2006 for Haystack API by  doxygen 1.4.7