Open MuhammadNouman opened 6 years ago
I took me a while but I got it working, I hope helps others, after installing with componser yo need to create your sanbox page, for me was a index,php in /vendor/kevinem/adobe-sign-php/ then you need to include 2 classes AdobeSign and Psr7 in my case, because I need to upload 2 documments.
require "../../../vendor/autoload.php"; use KevinEm\AdobeSign\AdobeSign; use GuzzleHttp\Psr7;
here is how I configure the $provider
`$archivos = ['/YOUR_PATH/VFirma_FEA_01.pdf', '/YOUR_PATH/505.pdf'];
//YOUR_BACK_URL must be the same as your backend in adobe //dataCenter make sure what server you need, change this manually in AdobeSign.php
$provider = new KevinEm\OAuth2\Client\AdobeSign([ 'clientId' => 'YOUR_APP_ID', 'clientSecret' => 'YOUR_APP_SETRET', 'redirectUri' => 'YOUR_BACK_URL', 'dataCenter' => 'secure.na2', 'scope' => ['user_login:self', 'agreement_write:self', 'widget_write:self', 'library_write:self', 'agreement_send:self' ] ]);`
`$accessToken = $adobeSign->getAccessToken($_GET['code']); $adobeSign->setAccessToken($accessToken->getToken()); $todosDoc = array(); foreach ($archivos as $doc) { $file_path = DIR.$doc; $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); array_push($todosDoc, $transient_document); }
$adobeSign->createAgreement([
'documentCreationInfo' => [
'fileInfos' => $todosDoc,
'name' => 'My Document Test',
'signatureType' => 'ESIGN',
'recipientSetInfos' => [
'recipientSetMemberInfos' => [
'email' => 'orlando@yoursigner.com'
],
'recipientSetRole' => [
'SIGNER'
]
],
'mergeFieldInfo' => [
[
'fieldName' => 'Name',
'defaultValue' => 'John Doe'
]
],
'signatureFlow' => 'SENDER_SIGNATURE_NOT_REQUIRED'
]
]);`
I took me a while but I got it working, I hope helps others, after installing with componser yo need to create your sanbox page, for me was a index,php in /vendor/kevinem/adobe-sign-php/ then you need to include 2 classes AdobeSign and Psr7 in my case, because I need to upload 2 documments.
require "../../../vendor/autoload.php"; use KevinEm\AdobeSign\AdobeSign; use GuzzleHttp\Psr7;
here is how I configure the $provider
`$archivos = ['/YOUR_PATH/VFirma_FEA_01.pdf', '/YOUR_PATH/505.pdf'];
//YOUR_BACK_URL must be the same as your backend in adobe //dataCenter make sure what server you need, change this manually in AdobeSign.php
$provider = new KevinEm\OAuth2\Client\AdobeSign([ 'clientId' => 'YOUR_APP_ID', 'clientSecret' => 'YOUR_APP_SETRET', 'redirectUri' => 'YOUR_BACK_URL', 'dataCenter' => 'secure.na2', 'scope' => ['user_login:self', 'agreement_write:self', 'widget_write:self', 'library_write:self', 'agreement_send:self' ] ]);`
`$accessToken = $adobeSign->getAccessToken($_GET['code']); $adobeSign->setAccessToken($accessToken->getToken()); $todosDoc = array(); foreach ($archivos as $doc) { $file_path = DIR.$doc; $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); array_push($todosDoc, $transient_document); }
$adobeSign->createAgreement([ 'documentCreationInfo' => [ 'fileInfos' => $todosDoc, 'name' => 'My Document Test', 'signatureType' => 'ESIGN', 'recipientSetInfos' => [ 'recipientSetMemberInfos' => [ 'email' => 'orlando@yoursigner.com' ], 'recipientSetRole' => [ 'SIGNER' ] ], 'mergeFieldInfo' => [ [ 'fieldName' => 'Name', 'defaultValue' => 'John Doe' ] ], 'signatureFlow' => 'SENDER_SIGNATURE_NOT_REQUIRED' ] ]);`
mhh....where do you use $provider var?
$adobeSign = new AdobeSign($provider); @itajackass
@mcbosc thanks after a lot I find that it was not present. But I still get error on the script, $_GET['code'] never found... so i implemented all the code without kevinem script but only with cURL.
Now i get another trouble.
Do you use custom form fields? I can't place it. It seem adobesign ignore my inserts. Please do you have some example of working?
Mine is this:
$header =array(
"Authorization: Bearer " . $access_token,
"cache-control: no-cache",
"content-type: application/json"
);
$fields_array = array(
"fields" => [array(
"locations" => [array(
"height" => 36,
"left" => 75,
"pageNumber" => 2,
"top" => 200,
"width" => 150
)]
,
"contentType" => "SIGNER_COMPANY",
"name" => "sigBlock1",
"backgroundColor" => "#CCCCCC",
"inputType" => "TEXT_FIELD",
"required" => true,
"visible" => true
)]
);
$postdata = json_encode($fields_array);
$resource = curl_init();
curl_setopt_array($resource, array(
CURLOPT_URL => "https://api.eu1.echosign.com/api/rest/v6/agreements/" . $id . "/formFields",
CURLOPT_HTTPHEADER => $header,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => $postdata,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_SSL_VERIFYPEER => false
));
$res = curl_exec($resource);
Hello, I am new to this composer stuff, need to know how can I use this api wrapper? I have downloaded the code and isntalled using composer command, everythins is downloaded I have ID and secret from Adobe, how can I run tests? it is throwing errors like
'PHPUnit_Framework_TestCase' not found in D:\wamp6...
when I open any php file, it throws errpr