简体   繁体   English

Zend Gdata日历:具有完全词组匹配的setQuery吗?

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

I am having trouble using Zend_Gdata_Calendar to return a subset of Google Calendar events with an exact phrase match. 我在使用Zend_Gdata_Calendar返回带有精确短语匹配的Google日历事件子集时遇到问题。

The reference guide for Zend_Gdata_Books , in the setQuery() section, suggests this should be possible with Zend: Zend_Gdata_Books参考指南setQuery()部分中,建议使用Zend可以实现:

Note that any spaces, quotes or other punctuation in the parameter value must be URL-escaped (Use a plus (+) for a space). 请注意,参数值中的任何空格,引号或其他标点符号都必须转义URL(使用加号(+)表示空格)。 To search for an exact phrase, enclose the phrase in quotation marks. 要搜索确切的短语,请将该短语用引号引起来。 For example, to search for books matching the phrase "spy plane", set the q parameter to %22spy+plane%22 . 例如,要搜索与短语“间谍飞机”匹配的书籍,请将q参数设置为%22spy+plane%22

As far as I can tell, Zend_Gdata_Books and Zend_Gdata_Calendar extend the same setQuery() function, so I figure they're equivalent on the Zend end of things. 据我所知, Zend_Gdata_BooksZend_Gdata_Calendar扩展了相同的setQuery()函数,因此我认为它们在Zend方面是等效的。

As for Google, the Calendar query parameters reference says the Calendar API supports the standard Data API query parameters, which in turn says the full-text query string q supports case-insensitive exact phrase searching, just as Zend_Gdata_Books indicates. 对于Google, Calendar查询参数参考说Calendar API支持标准的Data API查询参数,而后者又说全文查询字符串q支持不区分大小写的精确短语搜索,正如Zend_Gdata_Books指示的那样。

I've tried it all these ways: 我已经尝试了所有这些方法:

$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

I realize the first two didn't work because the string is getting doubly URL-encoded. 我意识到前两个没有用,因为字符串已经被双重URL编码了。 In the latter cases, I am getting the event I want, but also events including "event" or "text" that I don't want. 在后一种情况下,我得到了我想要的事件,但也得到了我不想要的事件,包括“事件”或“文本”。

Could it be that Google has implemented the full-text query differently for the Calendar API? 难道Google对Calendar API实施了全文查询的方式有所不同? What kind of dumb things might I be doing on my end to break it? 我可能会做什么样的愚蠢的事情来打破它?

it looks like you want try it with $query->setQuery('"event text"'); 看起来您想使用$query->setQuery('"event text"');
which yields the query string of Query string(19) "?q=%22event+text%22" 生成Query string(19) "?q=%22event+text%22"Query string(19) "?q=%22event+text%22"
where $query->setQuery("event text"); 其中$query->setQuery("event text");
yields the query string of Query string(13) "?q=event+text" 产生Query string(13) "?q=event+text"Query string(13) "?q=event+text"

I used : 我用了 :

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

To test. 去测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM