Parse.com php托管中的问题 [英] problems in Parse.com php hosting

查看:76
本文介绍了Parse.com php托管中的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Parse.com PHP SDK为我的应用程序创建一个测试后端.似乎当我使用MAMP在localhost上部署PHP代码并在JSON字符串中获得完美结果时,但是当我尝试在免费托管站点上部署php代码时(在我的情况下,UltimateFreeHost.in可以托管php 5.4及以上代码) )我没有得到JSON响应,而是得到了HTML字符串.

I am creating a test backend for my app using the Parse.com PHP SDK. Seems that when I deploy the PHP code on localhost using MAMP and got perfect results in JSON strings but when I tried to deploy the php code on a free hosting site (in my case UltimateFreeHost.in which has capability to host php 5.4 and above codes) I don't get a JSON response instead I get HTML strings.

以下是我的php代码

<?php
// define location of Parse PHP SDK, e.g. location in "Parse" folder
// Defaults to ./Parse/ folder. Add trailing slash
define( 'PARSE_SDK_DIR', './Parse/' );

// include Parse SDK autoloader
require_once( 'autoload.php' );

// Add the "use" declarations where you'll be using the classes
use Parse\ParseClient;
use Parse\ParseObject;
use Parse\ParseQuery;
use Parse\ParseACL;
use Parse\ParsePush;
use Parse\ParseUser;
use Parse\ParseInstallation;
use Parse\ParseException;
use Parse\ParseAnalytics;
use Parse\ParseFile;
use Parse\ParseCloud;

// Init parse: app_id, rest_key, master_key
ParseClient::initialize('OgSGF8N3zcXrDcfRfu0Kiek4WU9yewWstnP4dw9Z', 'bFAWDmGEzN9c9iiMYocWiQtO4IeOTNLdRjWlr52a', 'a4WjNhTCXycNQ6r1vasWTdIRjAvmRFEi1teGATY6');

// save something to class TestObject
$testObject = ParseObject::create("TestObject");
$testObject->set("foo", "Carva");
$testObject->save();
$response["success"] = 1;
$response["message"] = "Product successfully created.";
// echoing JSON response
echo json_encode($response);
?>

这是我在本地主机上的回复

this is my response on localhost

这是我在互联网上的免费主机上部署时的回复

This is my response when deployed on free host on internet

我还要提及的是,当我用chrome浏览PHP文件的URL时,会得到所需的JSON响应.

I also would like to mention that when I hit the URL of the PHP file in chrome I get the desired JSON response.

请帮助我,我是后端开发的新手,请帮助我弄清基础知识

Please help me I am new to backend development help me clear my basics

推荐答案

假设您没有使用免费托管服务托管任何HTML或JavaScript,托管服务似乎将您的网站内容与自己的广告内容包装在一起

Assuming that you aren't hosting any HTML or JavaScript with your free host, it appears as though the host is wrapping your website's content with their own content for ads.

许多免费的主机会占用您网站的内容,并添加自己的HTML和/或Javascript来显示广告.如果您的主机正在执行此操作,那么它将不是适合JSON API的主机.

Many free hosts take your website's content and add their own HTML and/or Javascript to display advertisements. If your host is doing this, it will not be a suitable host for a JSON API.

这篇关于Parse.com php托管中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆