Skip to content

Instantly share code, notes, and snippets.

@Ahrengot
Last active September 21, 2015 14:14
Show Gist options
  • Save Ahrengot/95187ee2a4850a2bc617 to your computer and use it in GitHub Desktop.
Save Ahrengot/95187ee2a4850a2bc617 to your computer and use it in GitHub Desktop.
Helper to perform GET requests on Parse REST API
<?php
function parse_get($url) {
$app_id = 'PARSE_APP_ID';
$api_key = 'PARSE_API_KEY';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'X-Parse-Application-Id: ' . $app_id,
'X-Parse-REST-API-Key: ' . $api_key
));
$result = curl_exec($curl);
curl_close($curl);
return $result;
}
$user = json_decode( parse_get('https://api.parse.com/1/users/' . $user_id) );
print_r($user);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment