Skip to content

Instantly share code, notes, and snippets.

@niraj-shah
Created July 3, 2014 12:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niraj-shah/a85a740d49e2bed1d53f to your computer and use it in GitHub Desktop.
Save niraj-shah/a85a740d49e2bed1d53f to your computer and use it in GitHub Desktop.
Parse.com PHP SDK - Using Pointers and ACL
<?php
require_once( 'Parse/parse.php' );
// User ID from User table
$user_id = 'QLaLLqjJWi';
// new Profile object
$parse = new parseObject('Profile');
// set DOB as date - uses strtotime
$parse->dob = $parse->dataType( 'date', '1985-01-01' );
// bio string data
$parse->bio = "I am a PHP developer";
// pointer to User table (parse Classes should have _ prefix.)
$parse->userId = $parse->dataType( 'pointer', array( '_User', $user_id ) );
// create ACL
$acl = new parseACL();
// public cannot read data
$acl->setPublicReadAccess( false );
// user can read data
$acl->setReadAccessForId( $user_id, true );
// save ACL to object
$parse->ACL = $acl->acl;
// save object to parse
$r = $parse->save();
print_r( $r );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment