problems in Parse.com php hosting

て烟熏妆下的殇ゞ 提交于 2019-12-13 05:21:08

问题


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.

following is my php code

<?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

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


回答1:


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.

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.



来源:https://stackoverflow.com/questions/33439515/problems-in-parse-com-php-hosting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!