2

現在、非営利団体向けの Gmail Contextual Gadget に取り組んでいます。Hello World アプリを構築することを目標に、https://developers.google.com/gmail/contextual_gadgetsにある公式の Google チュートリアルに従いました。

次のことを行いました。

  1. https://console.developers.google.com/でアプリを作成します。
  2. Google マーケットプレイス SDK を有効にする
  3. 適切な Extractor と Gadget URL を使用して、GMail コンテキスト ガジェットを有効にします。
  4. 非営利団体のユーザー向けにアプリを展開します。
  5. 「Hello World」を含むメールをお送りください。

ただし、これを機能させることはできません (電子メールの下に Hello World が表示されるはずです)。XM をホストしているサーバーを確認したところ、Google は確かに gadget_helloworld.xml ファイルにヒットしました。

ファイルの内容は次のとおりです。誰かがこの件について手を差し伸べてくれませんか?

Google API で多くのことが変更されたため、このトピックに関する最新のドキュメントを見つけるのは困難です。2015 年に更新されたコードのオープン ソースの作業サンプルを提供することは、コミュニティにとって役立つと思います。

一番、

Extractor の内容 - 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>
4

1 に答える 1

1

私はそれがアクティブにならないという同様の問題を抱えていました。私にとっての解決策は、「Extractor param name」を「hello」に設定し、「Extractor param value」を「.*」に設定することでした-ドキュメントによると重要一部は値フィールドです。

エクストラクタのデフォルト出力で可能なすべての値によってガジェットをトリガーしたい場合は、明示的に正規表現を value=".*" として設定します。これにより、意図的に広いネットをキャストしたことが明らかになります。

于 2016-02-15T02:24:49.773 に答える