Getting Started

Getting Started with PHP

Contents

Introduction

Verizon Personal Cloud Storage SDK for PHP allows you to develop apps for PHP platform which can access Verizon Personal Cloud Storage user content (subject to the user’s prior approval).

Before You Begin

Before you can start coding, you will need to:

  1. Obtain Key, Secret, and Callback URL.
  2. Install and configure Personal Cloud Storage SDK for PHP.

    NOTE: Minimum software requirements for the SDK:

    • PHP versioin 5.3
    • Apache
    • Curl
  3. Configure Your App.

1. Obtain Key, Secret, and Callback URL

Key, Secret, and Callback URL are established during registration. If you have not yet registered, follow the steps on the Getting Credentials to Use the Personal Cloud Storage APIs page in the API Developer Guide to register.

2. Install and Configure Personal Cloud Storage SDK for PHP

In order to download Verizon Personal Cloud Storage Android SDK, you must log on to ThingSpace Developer Portal and accept Verizon terms and conditions. If you start downloading the file without logging on, the download will stop and you will be redirected to the log on screen. Download will resume after a successful log on.

Installation on Mac

  1. Download and configure Apache Server for Mac.
  2. Download PHP SDK.
  3. Unzip PHP_SDK_X.X.zip file.
  4. Create a new folder for your project, such as My Project folder.
  5. Copy all files that you retrieve from PHP_SDK_X.X.zip to My Project folder.
  6. Place My Project folder in the Library/WebServer/Documents directory.
  7. Update config.php file with Key, Secret, and Callback URL. Refer to Authentication and Authorization page for detailed instructions.
  8. Use command line to grant appropriate level of permissions to base folder My Project:

    Code Sample

    sudo chmod -R 0755 /Library/WebServer/Documents/My Project
    
  9. Restart the server using the command:

    Code Sample

    – apachectl restart
    
  10. You can now access the codebase with the following URL. Note that this is also your local Callback URL:

    http://localhost/My Project/sample/index.php
    
  11. Starting page Kepler Cloud File Explorer appears. Click Sign In with Verizon Cloud and login with a your mobile number or ThingSpace credentials.

  12. You can now test the features.

Installation on Windows

  1. Download and configure Apache Server for Windows.
  2. Use XAMPP or WAMP to set up the environment for the SDK.
    • To install XAMPP:
      1. Go to Apache Friends website and download XAMPP for Windows.
      2. Follow the installation steps to install XAMPP.
      3. The location of the codebase should be htdocs folder of the installation directory.
    • To install WAMP:
      1. Download WAMP.
      2. Follow the installation steps to install WAMP.
      3. The location of the codebase should be the www folder of the installation directory.
  3. Once the installation completes, start the XAMPP or WAMP server by clicking on the XAMPP or WAMP icon.
  4. Start Apache. You do not need to start MYSQL.
  5. Create a folder with a name that you want to use for your app, such as My Project.
  6. Download PHP SDK.
  7. Unzip the code to My Project folder.
  8. Update config.php file with Key, Secret, and Callback URL. Refer to Authentication and Authorization page for detailed instructions.
  9. You can now access the project with the following url: http://localhost/My Project/sample/index.php

NOTES:
- Refer to the following Video Tutorial for instructions on how to install WampServer on Windows.
- Refer to the following Video Tutorial for instructions on how to install XAMPP on Windows 7.

Installation on Linux

  1. Download Apache Server for Linux.
  2. To install Apache, enter these commands:

Code Sample

sudo apt-get update
sudo apt-get install apache2
  1. To install PHP, enter these commands:

    Code Sample

    udo apt-get install php5 libapache2-mod-php5 php5-mcrypt
    
  2. Add PHP to the directory index, to serve the relevant PHP index files:

Code Sample

```php sudo nano /etc/apache2/mods-enabled/dir.conf


5. Add **index.php** to the beginning of index files, as follows:

    **Code Sample**

    ```php
<IfModule mod_dir.c>
DirectoryIndex index.php index.html index.cgi index.pl index.php index.xhtml index.htm
</IfModule>
  1. The location of the codebase should be /var/www/.
  2. Create a folder with a name that you want to use for the application, such as My Project.
  3. Download PHP SDK.
  4. Unzip the base to My Project folder.
  5. Update config.php file with Key, Secret, and Callback URL. Refer to Authentication and Authorization page for detailed instructions.
  6. You can now access the project at the following url: http://localhost/My Project/sample/index.php

3. Configure up Your App

Configuration Changes at Runtime

Before you can use your app, you must change the settings in the php.ini file to override the existing PHP configuraion.

To link a new php.ini file with your instance of Apache, follow these steps:

  1. Copy the default php.ini file into the /var/www/web1/ directory. You can find the php.ini in the following directory: - Debian and Ubuntu - /etc/php5/apache2/php.ini - Fedora and CentOS - /etc/php.ini
  2. Set up the www.example.com to use the php.ini from the /var/www/web1/ directory. - Debian and Ubuntu - cp /etc/php5/apache2/php.ini /var/www/web1/ - Fedora and CentOS - cp /etc/php.ini /var/www/web1/
  3. Modify /var/www/web1/php.ini as needed.
  4. Open the vhost configuration for the www.example.com web site and add a PHPINIDir line:

php <VirtualHost 1.2.3.4:80> [...] PHPINIDir /var/www/web1 [...] </VirtualHost> NOTE: PHPINIDir must contain the directory where the php.ini file for the web site is located.

  1. Restart Apache: - Debian and Ubuntu: /etc/init.d/apache2 restart - Fedora and CentOS: /etc/init.d/httpd restart
  2. For more information, refer to https://www.howtoforge.com/how-to-specify-a-custom-php.ini-for-a-website-apache2-with-mod_php.

Cross-Site Scripting (XSS)

To prevent XXS attacks, PHP Kepler Cloud File Explorer supports a third party library called htmlpurifier. All GET and POST requests are encoded.

NOTE: You can view the htmlpurifier license at https://github.com/ezyang/htmlpurifier/blob/master/LICENSE.

To use htmlpurifier in your app, create an object of htmlpurifier class using the following code sample:

$purifier = new HTMLPurifier();

You can now use this object to sanitize the user input and output. Use the code sample below:

$purifier→purify($_POST['form input name']);

Copyright © 2015-2017, Verizon and/or its Licensors. All rights reserved.