Example #1
0
    /**
     * @param string $filter
     * @param string $url
     *
     * @return array
     */
    function QueryCard($filter, $url = '')
    {
        $xml = '<?xml version="1.0" encoding="utf-8" ?>
<c:addressbook-query xmlns:d="DAV:" xmlns:c="' . \Sabre\CardDAV\Plugin::NS_CARDDAV . '">
	<d:prop>
		<d:getetag/>
		<c:address-data>
			<c:allprop />
		</c:address-data>
	</d:prop>
	' . $filter . '
</c:addressbook-query>';
        $res = array();
        try {
            $res = $this->client->request('REPORT', $url, $xml, array('Content-Type' => 'application/xml', 'Depth' => '1'));
        } catch (\Sabre\DAV\Exception $ex) {
            return false;
        }
        $aStatus = $this->client->parseMultiStatus($res['body']);
        $report = array();
        foreach ($aStatus as $key => $props) {
            $response = array();
            $response['href'] = basename($key);
            $response['etag'] = isset($props[200]) ? preg_replace('/^"?([^"]+)"?/', '$1', $props[200][self::PROP_ETAG]) : '';
            $response['data'] = isset($props[200]) ? $props[200][self::PROP_ADDRESSBOOK_DATA] : '';
            $report[] = $response;
        }
        return $report;
    }