Giter Site home page Giter Site logo

spotify-web-api-wrapper-php's Introduction

spotify-web-api-wrapper-php

PHP wrapper for the Spotify web API

Work in progress.

Getting started

Let say you have an php site in this folder,

Place the Spotify.php in your vendor, and create a basic api connection header

spotify.inc.php

<?php
require_once '../vendor/Spotify.php';

// Instansiate the SpotifyAPI class
$spotifyApi = new Spotify('CLIENT_ID', 'CLIENT_SECRET', 'http://joyify.se/callback.php');
?>

Then create a login page, login.php

<?php
require_once 'spotify.inc.php';
// We choose the permission scope to ask allowance for
$scope = array(
    'user-read-email', 
    'playlist-modify', 
    'playlist-read-private', 
    'playlist-modify-private', 
    'user-read-private', 
    'user-read-email');
    
// Then start the authorization flow by redirecting the user to the login page
$result = $spotifyApi->startAuthorization($scope);
$spotifyApi->startAuthorization();
?>

Let say you created a callback.php in the same directory as the login.php, just create a callback.php there (assume the pages we create can be reached at http://localhost/)

<?php
// Get the access token 
$token = $spotifyApi->requestToken();

// Store the refresh token and access token in your database
$access_token = $token['access_token'];
$refresh_token = $token['refresh_token'];
// Then 'install' the token into the class instance
$spotifyApi->authenticate($token['access_token']);
?>

spotify-web-api-wrapper-php's People

Contributors

brannon-bowden avatar drsounds avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.