• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Parse.com PHP Help please?

#1
[eluser]Unknown[/eluser]
Hi there,

Im a total newbie to php and CodeIgnitor (I'm a C# developer). However I have been tasked to make a CMS for parse.com which we are using as a backend for our apps. So I made a basic form from this page (https://ellislab.com/codeigniter/user-gu...ml#theform). Which is great and works fine, i am now trying to add the parse php sdk, I have followed the guidelines which has created a vendor file in my application/libraries amongst other things. Now if i call a function with any parse code in it my screen is white blank. Does this suggest that I haven't implemented the sdk properly? Does anyone have a very basic project that has the parse sdk implemented? here is some code, if i comment out the CreateObject function it works fine but if i uncomment i get the white blank screen.

Code:
<?php

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;

class Form extends CI_Controller {

function index()
{
  $this->load->helper(array('form', 'url'));

  $this->load->library('form_validation');

  $this->form_validation->set_rules('username', 'Username', 'callback_username_check');
  $this->form_validation->set_rules('password', 'Password', 'required');
  $this->form_validation->set_rules('passconf', 'Password Confirmation', 'required');
  $this->form_validation->set_rules('email', 'Email', 'required|is_unique[users.email]');

  if ($this->form_validation->run() == FALSE)
  {
   $this->load->view('myform');
  }
  else
  {
   $this->load->view('formsuccess');

   $this->CreateObject();
  }
}

  public function CreateObject ()
      {
        $user = new ParseUser();
   $user->set("username", "PHPTESTNAME");
   $user->set("password", "phptestname");
   $user->set("email", "[email protected]");

   try
   {
     $user.signUp();
      // Hooray! Let them use the app now.
   }
   catch (ParseException $ex)
   {
     // Show the error message somewhere and let the user try again.
     echo "Error: " . $ex->getCode() . " " . $ex->getMessage();
   }

      }

public function username_check($str)
{
  if ($str == 'test')
  {
   $this->form_validation->set_message('username_check', 'The %s field can not be the word "test"');
   return FALSE;
  }
  else
  {
   return TRUE;
  }
}
}
?>


Any help would be much appreciated.

Below is a link to a simple codeigniter project with the parse php sdk, if someone could tell me where I'm going wrong that would be great (the parse code is in welcome.php and I've removed my app keys etc so obviously this won't work)

https://www.dropbox.com/sh/rda2m8wm8bs5v...U816_KPJna

#2
[eluser]CroNiX[/eluser]
try $user = new Parse\ParseUser();

#3
[eluser]CroNiX[/eluser]
Blank screen usually indicates you have error reporting suppressed. Have you checked the apache and php log files?

#4
[eluser]Tim Brownlaw[/eluser]
Ok I downloaded and installed your script and I found the following...

Yep, you don't have error reporting enabled as it went to town complaining!
FATAL Error: Parse\ParseObject not found in welcome.php line 52 ( I moved things so it is around that ).

1. In your welcome.php

Code:
class Welcome extends CI_Controller {

public function __construct()
{
  parent::__construct();

Use Double Underscores for __construct()... You just had a single one. There was no error reported... I tested that the Constructor was being called with a simple

Code:
echo "hi I am the constructor";
die();
The reason I found this was the question - Why wasn't there massive complaints about Parse\ParseClient in the Constructor not being found?

2. The location of your Parse Folder... Move it up one level, which will put it outside of the application folder.

After I found the autoloader in the controllers folder, I got it to echo the actual path.
Once I moved the folder up a level I got the ole Authorization Errors and not the FATAL I cannot find Parse\ParseClient....

3. I see you have a Parse Folder with an Internal Folder with NO Files and a parse folder with just an internal folder with the Files.
I moved the parse/internal (lower case folder name parse) files into the Parse/internal folder (upper case folder name Parse) and deleted the whole parse folder.

So I now get as far as...

Code:
( ! ) Fatal error: Uncaught exception 'Parse\ParseException' with message 'unauthorized' in /home/ciparsedebug/public_html/Parse/ParseClient.php on line 259
( ! ) Parse\ParseException: unauthorized in /home/ciparsedebug/public_html/Parse/ParseClient.php on line 259

Which I am guessing is a good thing Smile

Cheers


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.