【问题标题】:Can a php web site connect to an existing Parse Server running on a different server?php 网站可以连接到在不同服务器上运行的现有 Parse 服务器吗?
【发布时间】:2019-05-25 16:15:34
【问题描述】:

我有 2 个 AWS 实例正在运行,一个带有网页,一个作为 iOS 应用程序的后端。我想在应用程序的 php 网站上使用驱动应用程序的实例中的一些图像和数据。有没有办法让我的 php 服务器连接到解析服务器?我四处搜索,看到一些文档建议使用 PHP 从同一个服务器访问解析,但我希望有一种方法可以从单独的服务器连接到解析服务器,基本上是应用程序连接到解析的方式快速代码?我的两台服务器都是从 AWS 市场上的 Bitnami 堆栈、PHP Bitnami 和 Parse Bitnami 在 AWS 上运行的实例。

【问题讨论】:

    标签: php amazon-web-services parse-platform parse-server


    【解决方案1】:

    是的,与您通过 iOS 应用程序访问它的方式相同 - 基于 https 的 REST API 调用。

    https://docs.parseplatform.org/rest/guide/

    对于 PHP,您可能需要查看 json_encodejson_decode 函数,以及用于 GET 请求的 file_get_contents(如果启用了 http 包装器)和/或用于 POST 的 CURL 模块/扩展、PUT、DELETE(如果 url 包装器被禁用,则为 GET)。

    https://www.php.net/manual/en/book.curl.php

    https://www.php.net/manual/en/function.json-decode.php

    https://www.php.net/manual/en/function.json-encode.php

    【讨论】:

      【解决方案2】:

      是的。 Parse Platform 有一个特定的 PHP SDK: https://docs.parseplatform.org/php/guide/

      只需在您的 PHP 应用程序中安装 SDK 并像这样初始化它:

      ParseClient::initialize('your app id', 'your rest key', 'your master key');
      ParseClient::setServerURL('https://your-parse-server-address:port','parse');
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-09-14
        • 2013-01-06
        • 2020-02-02
        • 2010-09-08
        • 2013-02-16
        相关资源
        最近更新 更多