Web Tamarin
  • Home
  • Plugins
    • MK Slider
    • MK Google Directions
    • MK Post and Page Excerpts Widgets
  • HIRE ME!!!
  • DONATE
  • Search
  • Menu Menu

Archive for category: Users

You are here: Home1 / Parse2 / Users

Parse.com Sign Up Using PHP CURL

July 31, 2014/in Parse, Users/by Web Tamarin

Parse.com is an external BaaS (Backend as a service) provider.

Parse.com provides REST API that lets you interact with Parse.com from anything that can send an HTTP Request. In this tutorial we will send and HTTP request to Parse.com using PHP CURL.

This tutorial assumes that you have Parse.com account. Follow the below mentioned steps to create a Parse.com App and obtain Application Id.

  1. Sign In to Parse.com 
  2. Move to Dashobard
  3. Create a New App
  4. Copy Application ID, Client Key and REST API Key

The code below will send a PHP CURL request to REST API of Parse.com to register a new user. While registering a new user on Parse.com the username and password fields are required, rest of the fields are optional. The password field is handled differently than the others; it is encrypted when stored in the Parse Cloud and never returned to any client request. You have to place you Application ID and REST API Key with the placeholders. You can run this code on a PHP server.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php
$url = 'https://api.parse.com/1/users';
$headers = array(
            "X-Parse-Application-Id: " . YOUR_APPLICATION_ID,
            "X-Parse-REST-API-Key: " . YOUR_REST_API_KEY,
            "Content-Type: application/json"
        );
$user_data = '{"username":"YOUR_USERNAME", "password":"YOUR_PASSWORD","phone":"YOU_PHONE"}';
 
$rest = curl_init();
curl_setopt($rest, CURLOPT_URL, $url);
curl_setopt($rest, CURLOPT_POST, 1);
curl_setopt($rest, CURLOPT_POSTFIELDS, $user_data);
curl_setopt($rest, CURLOPT_HTTPHEADER, $headers);
curl_setopt($rest, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($rest, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($rest);
print_r(json_decode($response));
curl_close($rest);
?>

 When the creation is successful, the HTTP response is a 201 Created and the Location header contains the URL for the new user:

1
2
Status: 201 Created
Location: https://api.parse.com/1/users/g7y9tkhB7O

 The response body is a JSON object containing the objectId, the createdAt timestamp of the newly-created object, and thesessionToken which can be used to authenticate subsequent requests as this user:

1
2
3
4
5
{
  "createdAt": "2011-11-07T20:58:34.448Z",
  "objectId": "g7y9tkhB7O",
  "sessionToken": "pnktnjyb996sj4p156gjtp4im"
}

 

https://www.webtamarin.com/wp-content/uploads/2014/09/parse.jpg 250 280 Web Tamarin https://www.webtamarin.com/wp-content/uploads/2015/06/logo11-300x62.png Web Tamarin2014-07-31 07:52:422020-02-13 12:08:03Parse.com Sign Up Using PHP CURL

Parse.com Sign In Using PHP CURL

July 31, 2014/in Parse, Users/by Web Tamarin

Parse.com is an external BaaS (Backend as a service) provider. 

Parse.com provides REST API that lets you interact with Parse.com from anything that can send an HTTP Request. In this tutorial we will send and HTTP Request to Parse.com using PHP CURL.

This tutorial assumes that you have Parse.com account.  Follow the below mentioned  steps to create a Parse.com App and obtain Application Id.

  1. Sign In to Parse.com 
  2. Move to Dashobard
  3. Create a New App
  4. Copy Application ID, Client Key and REST API Key

 The code below will send a PHP CURL request to  REST API of Parse.com. You have to place you Application ID and REST API Key with the placeholders. You can run this code on a PHP server.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
$url = 'https://api.parse.com/1/login/?username=YOUR_USERNAME&password=YOUR_PASSWORD';
$headers = array(
        "Content-Type: application/json",
        "X-Parse-Application-Id: " . YOUR_APPLICATION_ID,
        "X-Parse-REST-API-Key: " . YOUR_REST_API_KEY,
    );
 
$rest = curl_init();
curl_setopt($rest, CURLOPT_URL, $url);
curl_setopt($rest, CURLOPT_HTTPGET, true);
curl_setopt($rest, CURLOPT_HTTPHEADER, $headers);
curl_setopt($rest, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($rest, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($rest);
print_r(json_decode($response));
curl_close($rest);
 
?>

The response body is a JSON object containing all the user-provided fields except password. It also contains the createdAt,updatedAt, objectId, and sessionToken fields.

1
2
3
4
5
{
  "createdAt": "2011-11-07T20:58:34.448Z",
  "objectId": "g7y9tkhB7O",
  "sessionToken": "pnktnjyb996sj4p156gjtp4im"
}

 

https://www.webtamarin.com/wp-content/uploads/2014/09/parse.jpg 250 280 Web Tamarin https://www.webtamarin.com/wp-content/uploads/2015/06/logo11-300x62.png Web Tamarin2014-07-31 07:08:312020-02-13 12:08:03Parse.com Sign In Using PHP CURL


Search

Recent Posts

  • How to Reset WordPress Password
  • How to Change MX Records – Godaddy
  • PHP Best Practices That You Must Follow
  • Top PHP IDE’s
  • How To: Create aliases on WAMP server

Categories

Tags

Apache CakePHP Change MX Records CURL DNS Control Fix MX Records MX Records MySQL Parse Parse.com Parse.com Object Parse.com PHP Parse.com REST API Parse CURL Parse Objects Parse PHP Parse REST API PHP PHP Best Practices reset password wordpress Time to Live TTL Wamp Wamp Server wordpress database WordPress Debug Settings WordPress Development WordPress Memory Error WordPress Memory Limit wordpress mysql database WordPress Permalinks wordpress phpmyadmin WordPress Plugin WordPress Plugin Development WordPress Search Engine Friendly URL WordPress Security WordPress SEF URL Wordpress Sidebars WordPress Theme WordPress Theme Development Wordpress Widgets WordPress wp-config.php wp-config.php WP_MEMORY_LIMIT Zend Studio

Hire Me / Donate

Donate

Hire Me / Donate

Donate

Pages

  • Blog
  • MK Google Directions
  • MK Post and Page Excerpts Widgets
  • MK Slider
  • Plugins

Categories

  • Apache
  • Internet
  • MySql
  • Objects
  • Parse
  • PHP
  • Plugins
  • Themes
  • Users
  • Wamp
  • WordPress

Archive

  • June 2022
  • August 2015
  • July 2015
  • October 2014
  • September 2014
  • August 2014
  • July 2014
2018 - Enfold Theme by Kriesi
  • Twitter
  • Facebook
  • LinkedIn
Scroll to top