- $this->setToken($return['oauth_token'], $return['oauth_token_secret']);
-
- /* Subscription is finished and valid. Now store the new subscriber and the
- subscription in the database. */
-
- $this->datastore->saveProfile($listener);
- $this->datastore->saveSubscription($this->listener_uri,
- $this->listenee_uri,
- $this->token);
- }
-
- /**
- * Return the URI identifying the listener
- *
- * Returns the URI for the OMB user who tries to subscribe or already has
- * subscribed our user. This method is a workaround for a serious OMB flaw:
- * The Listener URI is not passed in the finishauthorization call.
- *
- * @access public
- *
- * @return string the listener’s URI
- **/
- public function getListenerURI() {
- return $this->listener_uri;
- }
-
- /**
- * Inform the service about a profile update
- *
- * Sends an updated profile to the service.
- *
- * @param OMB_Profile $profile The profile that has changed
- *
- * @access public
- **/
- public function updateProfile($profile) {
- $params = $profile->asParameters('omb_listenee', true);
- $this->performOMBAction(OMB_ENDPOINT_UPDATEPROFILE, $params, $profile->getIdentifierURI());
- }
-
- /**
- * Inform the service about a new notice
- *
- * Sends a notice to the service.
- *
- * @param OMB_Notice $notice The notice
- *
- * @access public
- **/
- public function postNotice($notice) {
- $params = $notice->asParameters();
- $params['omb_listenee'] = $notice->getAuthor()->getIdentifierURI();
- $this->performOMBAction(OMB_ENDPOINT_POSTNOTICE, $params, $params['omb_listenee']);
- }
-
- /**
- * Set the token member variable
- *
- * Initializes the token based on given token and secret token.
- *
- * @param string $token The token
- * @param string $secret The secret token
- *
- * @access public
- **/
- public function setToken($token, $secret) {
- $this->token = new OAuthToken($token, $secret);
- }
-
- /**
- * Prepare an OAuthRequest object
- *
- * Creates an OAuthRequest object mapping the request specified by the
- * parameters.
- *
- * @param string $action_uri The URI specifying the target service
- * @param array $params Additional parameters for the service call
- * @param string $method The HTTP method used to call the service
- * ('POST' or 'GET', usually)
- *
- * @access protected
- *
- * @return OAuthRequest the prepared request
- **/
- protected function prepareAction($action_uri, $params, $method) {
- $url = $this->services[$action_uri];
-
- $url_params = array();
- parse_str(parse_url($url, PHP_URL_QUERY), $url_params);
-
- /* Add OMB version. */
- $url_params['omb_version'] = OMB_VERSION;
-
- /* Add user-defined parameters. */
- $url_params = array_merge($url_params, $params);
-
- $req = OAuthRequest::from_consumer_and_token($this->oauth_consumer,
- $this->token, $method, $url, $url_params);
-
- /* Sign the request. */
- $req->sign_request(new OAuthSignatureMethod_HMAC_SHA1(),
- $this->oauth_consumer, $this->token);
-
- return $req;
- }
-
- /**
- * Perform a service call
- *
- * Creates an OAuthRequest object and execute the mapped call as POST request.
- *
- * @param string $action_uri The URI specifying the target service
- * @param array $params Additional parameters for the service call
- *
- * @access protected
- *
- * @return Auth_Yadis_HTTPResponse The POST request response
- **/
- protected function performAction($action_uri, $params) {
- $req = $this->prepareAction($action_uri, $params, 'POST');
-
- /* Return result page. */
- return $this->fetcher->post($req->get_normalized_http_url(), $req->to_postdata(), array());
- }
-
- /**
- * Perform an OMB action
- *
- * Executes an OMB action – to date, it’s one of updateProfile or postNotice.
- *
- * @param string $action_uri The URI specifying the target service
- * @param array $params Additional parameters for the service call
- * @param string $listenee_uri The URI identifying the local user for whom
- * the action is performed
- *
- * @access protected
- **/
- protected function performOMBAction($action_uri, $params, $listenee_uri) {
- $result = $this->performAction($action_uri, $params);
- if ($result->status == 403) {
- /* The remote user unsubscribed us. */
- $this->datastore->deleteSubscription($this->listener_uri, $listenee_uri);
- } else if ($result->status != 200 ||
- strpos($result->body, 'omb_version=' . OMB_VERSION) === false) {
- /* The server signaled an error or sent an incorrect response. */
- throw OMB_RemoteServiceException::fromYadis($action_uri, $result);
+
+ /**
+ * Perform a service call
+ *
+ * Creates an OAuthRequest object and execute the mapped call as POST
+ * request.
+ *
+ * @param string $action_uri The URI specifying the target service
+ * @param array $params Additional parameters for the service call
+ *
+ * @access protected
+ *
+ * @return Auth_Yadis_HTTPResponse The POST request response
+ */
+ protected function performAction($action_uri, $params)
+ {
+ $req = $this->prepareAction($action_uri, $params, 'POST');
+
+ /* Return result page. */
+ return $this->fetcher->post($req->get_normalized_http_url(),
+ $req->to_postdata(), array());
+ }
+
+ /**
+ * Perform an OMB action
+ *
+ * Executes an OMB action – as of OMB 0.1, it’s one of updateProfile and
+ * postNotice.
+ *
+ * @param string $action_uri The URI specifying the target service
+ * @param array $params Additional parameters for the service call
+ * @param string $listenee_uri The URI identifying the local user for whom
+ * the action is performed
+ *
+ * @access protected
+ */
+ protected function performOMBAction($action_uri, $params, $listenee_uri)
+ {
+ $result = $this->performAction($action_uri, $params);
+ if ($result->status == 403) {
+ /* The remote user unsubscribed us. */
+ $this->datastore->deleteSubscription($this->listener_uri,
+ $listenee_uri);
+ } else if ($result->status != 200 ||
+ strpos($result->body, 'omb_version=' . OMB_VERSION) === false) {
+ /* The server signaled an error or sent an incorrect response. */
+ throw OMB_RemoteServiceException::fromYadis($action_uri, $result);
+ }