kevinem / adobe-sign-php

AdobeSign PHP Client
MIT License
17 stars 16 forks source link

Installation #5

Open eshmatrix opened 7 years ago

eshmatrix commented 7 years ago

Installed using composer and added autoload file. and followed the Example Usage.

Fatal error: Class 'AdobeSign' not found in /opt/lampp/htdocs/adobe_sign/index.php on line 20

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

session_start();

$provider = new KevinEm\OAuth2\Client\AdobeSign([
    'clientId'          => 'client_id',
    'clientSecret'      => 'client_secret',
    'redirectUri'       => 'uri',
    'scope'             => [
          'user_read:self',
          'user_write:self',
          'user_login:self',
          'agreement_read:self',
          'agreement_write:self',
          'agreement_send:self'
    ]
]);

$adobeSign = new AdobeSign($provider);

if (!isset($_GET['code'])) {
    $authorizationUrl = $adobeSign->getAuthorizationUrl();
    $_SESSION['oauth2state'] = $provider->getState();
    header('Location: ' . $authorizationUrl);
} elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) {
    unset($_SESSION['oauth2state']);
    exit('Invalid state');
} else {
    $accessToken = $adobeSign->getAccessToken($_GET['code']);
    $adobeSign->setAccessToken($accessToken->getToken());
    $file_path = 'test.txt';
    $file_stream = Psr7\FnStream::decorate(Psr7\stream_for(file_get_contents($file_path)), [
        'getMetadata' => function() use ($file_path) {
            return $file_path;
        }
    ]);

    $multipart_stream   = new Psr7\MultipartStream([
        [
            'name'     => 'File',
            'contents' => $file_stream
        ]
    ]);

    $transient_document = $adobeSign->uploadTransientDocument($multipart_stream);

    print_r($transient_document);

}
?>

Please help to get rid from this.

vadiml commented 7 years ago

@eshmatrix

Replace line $adobeSign = new AdobeSign($provider); with $adobeSign = new KevinEm\AdobeSign\AdobeSign($provider);