Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function unsubscribe($savedSearchId, $userId, $use_auth = TRUE)
 {
     if ($use_auth) {
         $result = $this->oauth_client->authenticatedPostAsXml('savedSearch/' . $savedSearchId . '/unsubscribe', array('userId' => $userId));
     } else {
         $result = $this->oauth_client->consumerPostAsXml('savedSearch/' . $savedSearchId . '/unsubscribe', array('userId' => $userId));
     }
     $xml_element = $this->getXmlElementFromXmlString($result);
     $search_element = $xml_element->xpath('savedSearch');
     if (empty($search_element)) {
         $this->throwXmlElementException($xml_element, $result);
     }
     return $xml_element->xpath_str('message');
 }
 /**
  * Unsubscribe a user from a mailing.
  *
  * The object should be initialized with the consumer token and user access token of the user who is acted upon.
  *
  * @param string $user_id
  *   ID from user that needs to be unsubscribed.
  * @param string
  *   ID of the mailing to unsubscribe from.
  * @param bool $use_auth
  *   Using a consumer request for this method is only available for a few consumers who have the ‘Use Light UiTID permission.
  */
 public function unsubscribeFromMailing($user_id, $mailing_id, $use_auth = TRUE)
 {
     if ($use_auth) {
         $result = $this->oauth_client->authenticatedPostAsXml('mailing/v2/' . $mailing_id . '/unsubscribe', array('userId' => $user_id));
     } else {
         $result = $this->oauth_client->consumerPostAsXml('mailing/v2/' . $mailing_id . '/unsubscribe', array('userId' => $user_id));
     }
     $this->validateResult($result, self::CODE_MAILING_UNSUBSCRIBED);
 }
Beispiel #3
0
 /**
  * Performs a consumer authenticated POST request expecting a simple response.
  *
  * @param string $path
  *   Path to post to.
  * @param CultureFeed_Uitpas_ValueObject|array $data
  *   Post data.
  * @return \CultureFeed_Uitpas_Response
  *   The simple response.
  * @throws \CultureFeed_ParseException
  *   When the returned payload is not valid XML.
  */
 private function consumerPostWithSimpleResponse($path, $data)
 {
     if (is_object($data) && $data instanceof CultureFeed_Uitpas_ValueObject) {
         $data = $data->toPostData();
     }
     $result = $this->oauth_client->consumerPostAsXml($path, $data);
     try {
         $xml = new CultureFeed_SimpleXMLElement($result);
     } catch (Exception $e) {
         throw new CultureFeed_ParseException($result);
     }
     $response = CultureFeed_Uitpas_Response::createFromXML($xml->xpath('/response', false));
     return $response;
 }