我目前正在为非营利组织制作Gmail上下文小工具。 我们遵循https://developers.google.com/gmail/contextual_gadgets上的官方Google教程,目标是构建Hello World应用程序。
我们做了以下事情:
但是,我们无法使其正常工作(它应该在电子邮件下面打印Hello World)。我们检查了托管XM的服务器,Google肯定会点击我们的gadget_helloworld.xml文件。
以下是文件内容。有人可以帮忙讨论这个问题吗?
很难找到有关此主题的最新文档,因为Google API已经改变了很多内容。我认为社区提供一个在2015年末更新的开源工作代码示例会很有帮助。
最佳,
提取器的内容 - manifest_helloworld.xml
<?xml version="1.0" encoding="UTF-8"?>
<ApplicationManifest xmlns="http://schemas.google.com/ApplicationManifest/2009">
<script id="tinyhippos-injected" />
<Extension id="HelloWorldExtractor" type="contextExtractor">
<Name>Hello World Extractor</Name>
<Url>google.com:HelloWorld</Url>
<Triggers ref="HelloWorld" />
<Scope ref="emailBody" />
<Scope ref="emailSubject" />
<Container name="mail" />
</Extension>
<Extension id="HelloWorld" type="gadget">
<Name>HelloWorld Gadget</Name>
<Url>XXXX_MY_DOMAIN/gadget_files/gadget_helloworld.xml</Url>
<Container name="mail" />
<!-- Uncomment this to enable Caja. -->
<!-- Param name="caja" value="enabled"/> -->
</Extension>
<Scope id="emailBody">
<Url>tag:google.com,2010:auth/contextual/extractor/BODY</Url>
<Reason>Necessary for reason 1</Reason>
</Scope>
<Scope id="emailSubject">
<Url>tag:google.com,2010:auth/contextual/extractor/SUBJECT</Url>
<Reason>Necessary for reason 2</Reason>
</Scope>
</ApplicationManifest>
小工具的内容 - gadget_helloworld.xml
<?xml version="1.0" encoding="UTF-8"?>
<Module>
<script id="tinyhippos-injected" />
<ModulePrefs title="Hello World" description="Matches and echoes 'Hello World' string in emails" height="20" author="ACME" author_email="test@example.com" author_location="Bermuda">
<!-- Declare feature dependencies. -->
<!--
This one is not specific to Gmail contextual gadgets.
-->
<Require feature="dynamic-height" />
<!--
The next feature, Caja, is optional, and is supported for
use only within test domains. Uncomment the tag only for
non-production gadgets.
-->
<!-- <Require feature="caja"/> -->
<!--
The next feature, google.contentmatch, is required for all
Gmail contextual gadgets.
<Param> - specify one or more comma-separated extractor IDs in
a param named "extractors". This line is overridden by the extractor ID
in the manifest, but is still expected to be present.
-->
<Require feature="google.contentmatch">
<Param name="extractors">google.com:HelloWorld</Param>
</Require>
</ModulePrefs>
<!--
Define the content type and display location. The settings
"html" and "card" are required for all Gmail contextual gadgets.
-->
<Content type="html" view="card"><![CDATA[<p>Hello World</p>
<script type="text/javascript">
<!-- Fetch the array of content matches. -->
matches = google.contentmatch.getContentMatches();
var matchList = document.createElement('UL');
var listItem;
var extractedText;
<!-- Iterate through the array and display output for each match. -->
for (var match in matches) {
for (var key in matches[match]) {
listItem = document.createElement('LI');
extractedText = document.createTextNode(key + ": " + matches[match][key]);
listItem.appendChild(extractedText);
matchList.appendChild(listItem);
}
}
document.body.appendChild(matchList);
gadgets.window.adjustHeight(100);
</script>]]></Content>
</Module>
答案 0 :(得分:1)
我有一个类似的问题,它没有激活,我的解决方案是将“Extractor param name”设置为“hello”,并将“Extractor param value”设置为“。*” - {{3重要的部分是值字段:
如果你真的希望所有可能的触发你的小工具 提取器的默认输出中的值,显式设置常规值 表达式为value =“。*”。这清楚表明你已经投了一个 宽网设计。