Mayur
Mayur

Reputation: 412

problems in Parse.com php hosting

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 enter image description here

This is my response when deployed on free host on internet

enter image description here

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

Upvotes: 0

Views: 155

Answers (1)

Bryan Herbst
Bryan Herbst

Reputation: 67189

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.

Upvotes: 2

Related Questions