【问题标题】:Submit PHP form in OpenSocial gadget在 OpenSocial 小工具中提交 PHP 表单
【发布时间】:2010-11-11 14:35:40
【问题描述】:

我正在尝试为iGoogle 实现一个OpenSocial 小工具。 我正在用 PHP 编写我的应用程序,然后使用 XML 小工具规范将其“包装”在一个开放社交容器中。

如果我在独立页面中运行我的 PHP,它可以正常工作,在 iGoogle 容器中,当我按下表单上的按钮时,它会显示“找不到网页”。

我在这里做错了什么?如果我想使用 PHP 实现我的小工具,这是正确的方法吗?这可能吗?

XML 小工具描述:

<?xml version="1.0" encoding="UTF-8"?>
<Module>
    <ModulePrefs title="Register interest 29">
        <Require feature="opensocial-0.8"/>
        <Require feature="views" />
        <Preload href="http://opensocial-resources.googlecode.com/svn/samples/tutorial/tags/api-0.8/gifts.json" />
    </ModulePrefs>
    <Content type="html" href="http://myserver.com/OpenSocialSamples/test7.php">
    </Content>
</Module>

我有test7.php 文件:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
        <title>Random DBpedia reader example</title>
    </head>

    <body>
        <form action="test7.php" method=post">
            Search: <input type=text name="searchString"><br>
            <input type=submit value="Get data" >
        </form>

        <br><br>
        <h3> Data Test: </h3>
        <?php
            if ($_GET['searchString']) {
                echo $_GET['searchString'];
            }
        ?>
    </body>
</html>

【问题讨论】:

    标签: php opensocial igoogle


    【解决方案1】:

    我发现如果使用 Content type="url" 而不是 "http" 可以正常工作

    【讨论】:

      【解决方案2】:

      在表单操作中使用test7.php 的完整路径。

      【讨论】:

      • 好发现!如果我想使用 PHP 实现我的小工具,这是正确的方法吗?这可能吗?
      • 我个人会编写一个小型 javascript 客户端并通过 gadgets.io.makeRequest 与我的服务器通信。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多