Last active
December 21, 2015 00:38
-
-
Save niraj-shah/6221502 to your computer and use it in GitHub Desktop.
Usefull Parse.com PHP Functions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once( 'parse/parse.php' ); | |
// Login to parse | |
$parseLogin = new parseUser(); | |
$parseLogin->username = 'username'; | |
$parseLogin->password = 'password'; | |
try { | |
$result = $parseLogin->login(); | |
if ( $result ) { | |
// success, set cookie | |
echo 'Login successful'; | |
} else { | |
// display error | |
echo 'Login error'; | |
} | |
} catch ( Exception $e ) { | |
echo 'Login error: ' . $e; | |
} | |
// Save to custom class | |
$parse = new parseObject('CustomClassName'); | |
$parse->foo = "bar"; | |
$result = $parse->save(); | |
print_r( $result ); | |
// Get from default User class | |
$parseGet = new parseObject('_User'); | |
$result = $parseGet->get( 'objectId' ); | |
print_r( $result ); | |
// Get from custom class | |
$parseGet = new parseObject('CustomClassName'); | |
$result = $parseGet->get( 'objectId' ); | |
print_r( $result ); | |
// Find from default User class | |
$parseQuery = new parseQuery('_User'); | |
$parseQuery->where('name', 'Niraj Shah'); | |
$result = $parseQuery->find(); | |
print_r( $result ); | |
// Find from custom class | |
$parseQuery = new parseQuery('CustomClassName'); | |
$parseQuery->where('foo', 'bar'); | |
$result = $parseQuery->find(); | |
print_r( $result ); | |
// Update row in custom class | |
$parseUpdate = new parseObject('CustomClassName'); | |
$parseUpdate->foo = "foo"; | |
$result = $parseUpdate->update( '0rYHj1Wtzu' ); | |
print_r( $result ); | |
// Delete from custom class | |
$parseDelete = new parseObject('CustomClassName'); | |
$result = $parseDelete->delete( 'objectId' ); | |
print_r( $result ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment