/adobe-sign-csv2json

PHP based script to get csv "form data" using Adobe Sign agreement ID, convert to JSON and return

Primary LanguagePHPMIT LicenseMIT

adobe-sign-csv2json

PHP based script to get JSON from the csv "form data" using Adobe Sign agreement ID

It converts CSV to JSON and returns as response data

This script was written in PHP using php cURL code as generated by POSTMAN as well as swiping the code from the Gist from @robflaherty as found here https://gist.github.com/robflaherty/1185299 . Thanks rob!

How does it work ?

You just pass the Adobe Sign API related agreement ID, an API access token or integration key, and the "shard" of your account. You can get the shard from the URL after login. It will be the "na1", "na2", "eu1", etc. segment from the address which from one of my test accounts looks like this: https://hostname.na2.echosign.com/account/home. In this case my "shard" is na2 but yours will vary. The script uses this info to pass the agreement ID to the Adobe Sign REST api (V6) to get the CSV formatted "formData" response, then converts it to JSON and returns as "pretty" formatted JSON Data (example below).

Requirements

  • PHP Server running 5.6.40 - (May work with other 5.x versions or newer but this has not been tested)
  • Adobe Sign account allowing api access
  • Adobe Sign "integration key" or API oAuth token to access the API

Usage

Once you have this script installed on your php server you can POST to the page like below:

POST - URL https://yourserver.yourdomain.com/formDataJson.php

JSON Body
{
    "agreementInfo": {
        "agreement_id": "{{your agreementID here}}",
        "token": "{{your api token or integration key here}}",
        "sender_email": "{{your x-api-user email address here}}",
        "shard": "{{your account shard here}}"
    }
}

Response Example

In the example below there are 2 signers, each of which has a row in the CSV response from Adobe Sign. There are 7 params that are defaults returnd on most agreements. There is an ordinal "id" corresponding to the row for each signer.

  • completed
  • email
  • role
  • first
  • last
  • title
  • company

The remainder of the data is from the "columns" in the CSV corresponding to the fields on the form signed.

{
	"completed": "2019-05-16 09:46:44",
	"email": "echosmusz1+na2main@gmail.com",
	"role": "SIGNER",
	"first": "Samuel",
	"last": "Tanenbaum",
	"title": "CEO",
	"company": "Some Test Company 1",
	"City": "Cityville",
	"St": "OK",
	"Zip": "46832",
	"agreementId": "CBJCHBCAABAAyDr*********_WsSl-Ch6OUFIeHzWJp1",
	"city1": "Cityville",
	"city2": "Townville",
	"largeField2": "A bunch of text in largefield2",
	"street": "123 South Main",
	"id": 0
}, {
	"completed": "2019-05-16 09:50:04",
	"email": "echosmusz1+npssender2@gmail.com",
	"role": "SIGNER",
	"first": "Jack",
	"last": "Johnson",
	"title": "Consultant",
	"company": "Some Test Company 2",
	"City": "Cityville",
	"St": "OK",
	"Zip": "46832",
	"agreementId": "CBJCHBCAABAAyDr*********_WsSl-Ch6OUFIeHzWJp1",
	"city1": "Cityville",
	"city2": "Townville",
	"largeField2": "A bunch of text in largefield2",
	"street": "123 South Main",
	"id": 1
}