2

I am trying to use Parse in a php script.

I have done to following:

Uploaded the files 'autoload.php' and the folder 'Parse' from here to the root directory of the server https://github.com/parseplatform/parse-php-sdk

Then I created an index.php with the following test code from here: https://www.webniraj.com/2014/08/05/parse-com-using-the-official-parse-php-sdk-v1-0-x/

// 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('xxx', 'xxx', 'xxx');
// save something to class TestObject
$testObject = ParseObject::create("TestObject");
$testObject->set("foo", "bar");
$testObject->save();
// get the object ID
echo $testObject->getObjectId();
echo '<h1>Users</h1>';
// get the first 10 users from built-in User class
$query = new ParseQuery("_User");
$query->limit(10);
$results = $query->find();
foreach ( $results as $result ) {
// echo user Usernames
echo $result->get('username') . '<br/>';
}

Of course I replaced the xxx with my app_id, rest_key and master_key

When I now open index.php I am getting Fatal error: Call to undefined function Parse\curl_init() in /Parse/ParseClient.php on line 304

Did I miss to do something?

5
  • 1) what is the error? 2) if you went with copy/paste, did you change spl_autoload_register since that's searching for /src/Parse, not just /Parse Commented Jan 14, 2016 at 21:02
  • Error is "Server Error 500" when I open index.php in a browser the Parse files are just in the folder /Parse and not /scr/Parse Commented Jan 14, 2016 at 21:14
  • My bad. didn't see you defined PARSE_SDK_DIR Commented Jan 14, 2016 at 21:16
  • Tried it on another server: Fatal error: Call to undefined function Parse\curl_init() in /Parse/ParseClient.php on line 304 Commented Jan 14, 2016 at 21:58
  • Do you know whether you have CURL support installed for php? Also, what sort of server are you running on? Commented Jan 15, 2016 at 0:27

1 Answer 1

1

I don't have enough reputation points to simply comment, but wanted to suggest you confirm that you have the curl PHP extension installed on your server.

phpinfo();

or

if (extension_loaded("curl"))
{
    echo "cURL extension is loaded<br>";
}    
else
{
    echo "cURL extension is not available<br>";
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.