簡體   English   中英

Zend Gdata日歷:具有完全詞組匹配的setQuery嗎?

[英]Zend Gdata Calendar: setQuery with exact phrase match?

我在使用Zend_Gdata_Calendar返回帶有精確短語匹配的Google日歷事件子集時遇到問題。

Zend_Gdata_Books參考指南setQuery()部分中,建議使用Zend可以實現:

請注意,參數值中的任何空格,引號或其他標點符號都必須轉義URL(使用加號(+)表示空格)。 要搜索確切的短語,請將該短語用引號引起來。 例如,要搜索與短語“間諜飛機”匹配的書籍,請將q參數設置為%22spy+plane%22

據我所知, Zend_Gdata_BooksZend_Gdata_Calendar擴展了相同的setQuery()函數,因此我認為它們在Zend方面是等效的。

對於Google, Calendar查詢參數參考說Calendar API支持標准的Data API查詢參數,而后者又說全文查詢字符串q支持不區分大小寫的精確短語搜索,正如Zend_Gdata_Books指示的那樣。

我已經嘗試了所有這些方法:

$gCal = new Zend_Gdata_Calendar();
$query = $gCal->newEventQuery();

$query->setQuery("%22event+text%22"); //no results
$query->setQuery("%22event%20text%22"); //no results
$query->setQuery("\"event text\""); //too many results
$query->setQuery('"event text"'); //too many results
$query->setQuery("event text"); //too many results

我意識到前兩個沒有用,因為字符串已經被雙重URL編碼了。 在后一種情況下,我得到了我想要的事件,但也得到了我不想要的事件,包括“事件”或“文本”。

難道Google對Calendar API實施了全文查詢的方式有所不同? 我可能會做什么樣的愚蠢的事情來打破它?

看起來您想使用$query->setQuery('"event text"');
生成Query string(19) "?q=%22event+text%22"Query string(19) "?q=%22event+text%22"
其中$query->setQuery("event text");
產生Query string(13) "?q=event+text"Query string(13) "?q=event+text"

我用了 :

$gCal = new Zend_Gdata_Calendar();
        $query = $gCal->newEventQuery();
        $query->setQuery("event text");
        Zend_Debug::dump($query->getQueryString(), 'Query');

去測試。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM