PHP code example of hansadema / jsconnect

1. Go to this page and download the library: Download hansadema/jsconnect library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hansadema / jsconnect example snippets




tup a Jsconnect instance
$jsConnect = new \HansAdema\JsConnect\JsConnect('YOUR CLIENT ID', 'YOUR CLIENT SECRET');

// Build a user object
$user = new \HansAdema\JsConnect\User([
    'id' => 1234,
    'name' => 'Example User',
    'email' => '[email protected]',
    'photoUrl' => 'http://example.com/user.jpg',
    'roles' => ['member', 'administrator'],
]);

// Try to build the response
$response = $jsConnect->buildResponse($user, $_GET);

// Return the JSONP result
echo $_GET['callback'].'('.json_encode($response).')';

$response = [
    'error' => 'invalid_client',
    'message' => 'Your Custom Error Message',
];