How can i send docusign envelop to multiple recipient? - php

I have one question regarding docusign api. I am using docusign api for electronic-sign. In my requirement the recipient view does not show on the docusign website and only show on my website where user can do e-sign for the document. Basically i done this. My question start now. How can i add two recipient on the document. I try it with single recipient but not know how to use multiple recipient. Here in two recipient(person) one is me and other is my client who purchase product from me. When i send this envelop to my client. It will come first to me and then after my sign will go to my client side and wait for its sign. How can i do this priorities also?
require_once './docusign-php-client/src/DocuSign_Client.php';
require_once './docusign-php-client/src/service/DocuSign_RequestSignatureService.php';
require_once './docusign-php-client/src/service/DocuSign_ViewsService.php';
$clientConfig = array(
// Enter your Integrator Key, Email, and Password
'integrator_key' => "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", 'email' => "xxxxxxxxxxxxxxxxxxxxxx", 'password' => "xxxxxxxxxxxxxxxxxx",
// API version (v2 is latest) and environment (i.e. demo, www, etc)
'version' => 'v2', 'environment' => 'demo'
);
// Instantiate client and call the Login API
$client = new DocuSign_Client($clientConfig);
// create service object and configure envelope settings, document(s), and recipient(s)
$service = new DocuSign_RequestSignatureService($client);
$emailSubject = "Please sign this document.";
$emailBlurb = "This is a document from Developer who test this docusign app. I would like to work with this.";
// add one signHere tab for the recipient located 100 pixels right and
// 150 pixels down from the top left corner of document's first page
$tabs1 = array( "signHereTabs" => array(
array( "documentId" => "2",
"pageNumber" => "1",
"xPosition" => "450",
"yPosition" => "233" )));
// $tabs2 = array( "signHereTabs" => array(
// array( "documentId" => "2",
// "pageNumber" => "1",
// "xPosition" => "130",
// "yPosition" => "233" )));
$signed_document_id = time();
// add a recipient and document to the envelope
$recipients = array( new DocuSign_Recipient( "1", "1", "I am", "my-email#my-email.in", $signed_document_id, 'signers', $tabs1) );
$documents = array( new DocuSign_Document("TEST.PDF", "1", file_get_contents("BCD.pdf")) , new DocuSign_Document("TEST.PDF", "2", file_get_contents("ABC.pdf")) );
// "sent" to send immediately, "created" to save as draft in your account
$status = 'sent';
//*** Create and send the envelope with embedded recipient
$response = $service->signature->createEnvelopeFromDocument( $emailSubject, $emailBlurb, $status, $documents, $recipients, array() );
/**************************************************/
/* Step- 3 Embadded sign iframe */
/**************************************************/
$service = new DocuSign_ViewsService($client);
$envelopeId = $response->envelopeId;
$returnUrl = "https://demo.docusign.com;
$authMethod = "email";
$response = $service->views->getRecipientView( $returnUrl,
$envelopeId,
"i am",
"my-email#my-email.in",
$signed_document_id,
$authMethod );
$sign_url = $response->url;

Yes, you can have two different people sign a document via DocuSign, where both are signing within your application.
This is called "embedded signing."
Create the envelope (signing request) with both signers. You must supply a clientUserId field for both recipients.
The result of envelope create is an envelope_id. Use it with the getRecipientView method to obtain the url for the first signer.
Redirect the signer to the url to sign. After signing, the signer's browser is re-directed back to your application. You can use an iframe but it is not recommended if there is any chance that people will be signing via a mobile/tablet device.
Later on, the other signer will log into your application. At that time, you can repeat the previous steps to enable the second signer to sign.
Remember that when you enable someone to sign from within your application, your app is responsible for authenticating the signer.
More information: see the recipe for embedded signing.

Related

How to get content of message from users in my site using twilio

How are you everyone?
My site is based on PHP.
I am new with twilio and building simple project with this.
So what I should implement is to send messages to users using twilio and then receive message from users again in my site.
<?php
// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once './vendor/autoload.php';
use Twilio\Rest\Client;
// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = 'Azzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz';
$token = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$twilio = new Client($sid, $token);
$message = $twilio->messages
->create("+12099216581", // to
[
"body" => "This is test",
"from" => "+15324394442",
"statusCallback" => ""
]
);
print($message->sid);
This is for sending message to one users that I am using now..
Then...
<?php
require_once './vendor/autoload.php';
use Twilio\TwiML\MessagingResponse;
$response = new MessagingResponse();
$response->message('This is message 1 of 2.');
$response->message('This is message 2 of 2.');
echo $response;
I think this code will return text message to users with text...
If I am wrong, Please teach me...
So I am trying to do it now, but I can't know how to receive the content of message in my site.
If you are experience in this fields, Please teach me.
Thanks in advance.
You need to set the webhook for that messaging response
smsUrl = 'url';
$response = $client->request("POST", "IncomingPhoneNumbers/$phone_id.json", ['auth' => [$sid, $token], 'form_params' => array("SmsUrl" => $webhook_url, "BundleSid" => $bundle_id)]);
this URL will post the incoming message and reply message

Hey, How to collect sms Consent in laravel from klaviyo php-sdk in laravel

Hey guys does anyone knows the way around to add an SMS content in klaviyo from this package in laravel.
Basically I've added this piece of code where I can add the profile and see that green check next to user's email but for SMS it don't appear there. After reading some similar issues faced by others, I found that we need a subscribe endpoint of API to add consent of SMS, But I still can't find a way to do it with this package. Any help and suggestions would be appreciated.
use Klaviyo\Klaviyo as Klaviyo;
use Klaviyo\Model\EventModel as KlaviyoEvent;
use Klaviyo\Model\ProfileModel as KlaviyoProfile;
class KlaviyoformsController extends Controller
{
public function index()
{
$client = new Klaviyo('Your_private_key', 'public key');
$event =
new KlaviyoEvent(
array(
'event' => 'Lead',
'customer_properties' => array(
'$email' => "someone#mailinator9.com",
'$consent' => ['sms', 'email'],
'sms_consent' => true,
'email_consent' => true,
'$first_name' => "Thomas9",
'$last_name' => "Jefferson",
'$phone_number' => "1234567890"
),
'properties' => array()
)
);
$client->publicAPI->track( $event, true );
return view('klaviyoform::dashboard.index');
}
}
```
You must have a capture form for the consent submission within Laravel that will then subscribe them with the appropriate consent data. You must explicitly ask for both email and sms consent.
$client = new Klaviyo('Your_private_key', 'public key');
$customer_properties = [
'$email' => "someone#mailinator9.com",
'$first_name' => "Thomas9",
'$last_name' => "Jefferson",
'phone_number' => "1234567890"
];
$consents = [];
if (request()->get('sms_consent', false)) {
$consents['sms_consent'] = true;
}
if (request()->get('email_consent', false)) {
$consents['email_consent'] = true;
}
foreach ($consents as $type => $consented) {
if ($consented) {
$consents['$consent'] = array_merge(
data_get($consents, '$consent', []),
[explode('_', $type)[0]] //e.g. sms, email
);
}
}
$client->lists->addSubscribersToList('ListId', array_merge($customer_properties, $consents));
This is relative psuedo code but the goal is clear: Determine if they allowed both sms and email consent. If so, we'll add their consent properties.
Once the consent data has been added to that list you can safely send them sms and/or email based on the customers choice.

Is Google Drive API broken? I can't make it to send email notification

today i have got a problem with receiving a notification email after creating a new file to Google Drive through the API and sharing it with another email. I was using "sendNotificationEmail" => true and it was working for 1+ year. Today it's not working and i couldn't find anything about that. I am using a service account for that. I tried to create a file manually and share it with the same email i used through the API and it worked ( I received an email notification on the chosen email address ). Here is a code sample.
$share_email = "foo#example.com";
$filename = "This is a title";
$content = "This is a content";
$credentialsFile = PATH_TO_JSON;
$client = new Google_Client();
$client->setApplicationName('gdocs');
$client->setAuthConfig($credentialsFile);
$client->setScopes([
'https://www.googleapis.com/auth/drive',
'https://www.googleapis.com/auth/userinfo.email'
]);
$gDrive = new Google_Service_Drive($client);
$file = new \Google_Service_Drive_DriveFile();
$file->setName($filename);
$file->setMimeType('text/plain');
$file = $gDrive->files->create($file, [
'data' => $content,
'mimeType' => 'text/plain'
]);
$permission = new Google_Service_Drive_Permission();
$permission->setType('user');
$permission->setRole('writer');
$permission->setEmailAddress($share_email);
$gDrive->permissions->create($file->getId(), $permission, array(
'fields' => 'id',
'sendNotificationEmail' => true
));
Result: foo#example.com gets the shared file, but doesn't receive any email.
Expected result: foo#example.com receives email as well as the shared file.
Is there anyone experiencing the same problem or anyone knowing a fix about that ?
P.S. I am using v3 of the API.
P.S.2 I tried with oAuth2 and it's working great ( the email i am sharing a file with is receiving a notification ).. However i would like to keep using it with a service account if possible.

twilio SMS not received in mobile trial account

I have created trial account on twilio and used test API credentials for sending the SMS, after sending the SMS it shows me SID in success but no message received by the phone number which i have added in 'TO' field.
You must use live credentials to send messages:
<?php
// this line loads the library
require('/path/to/twilio-php/Services/Twilio.php');
// you must use your live credentials!!!!
$account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$auth_token = '[AuthToken]';
$client = new Services_Twilio($account_sid, $auth_token);
$client->account->messages->create(array(
'To' => "+15558675309",
'From' => "+15017250604",
'Body' => "Hey, hope this works!",
'MediaUrl' => "http://farm2.static.flickr.com/1075/1404618563_3ed9a44a3a.jpg",
));
It is explained here - https://www.twilio.com/docs/api/rest/test-credentials - test credentials do not connect to real phone numbers.

SOAP authentication with PHP

I need to connect to a web service that requires authentication credentials in the form of a plain text user name and password.
I have a basic understanding of SOAP and have managed to connect to other open web services that do not require a username or password using NuSOAP.
The following was sent to me:
<?php
// Set up security options
$security_options = array("useUsernameToken" => TRUE);
$policy = new WSPolicy(array("security" => $security_options));
$security_token = new WSSecurityToken(array(
"user" => "xxx",
"password" => "xxx",
"passwordType" => "basic"));
// Create client with options
$client = new WSClient(array("wsdl" => "https://xxx.asmx?wsdl",
"action" => "http://xxx",
"to" => "https://xxx",
"useWSA" => 'submission',
"CACert" => "cert.pem",
"useSOAP" => 1.1,
"policy" => $policy,
"securityToken" => $security_token));
// Send request and capture response
$proxy = $client->getProxy();
$input_array = array("From" => "2010-01-01 00:00:00",
"To" => "2010-01-31 00:00:00");
$resMessage = $proxy->xxx($input_array);
?>
After some research I understand that the above implementation uses wso2. I need to be able to do this without using wso2.
I have tried my best to look for resources (Google, forums, etc) about the above but haven't been able to find anything. I have read some tutorials on SOAP and have been able to set up a SOAP client using PHP but cannot get my head around all the authentication and "policies".
An explanation of how to achieve this and maybe some links to further reading about this would be very much appreciated as I am tearing my hair out! Ideally I would like some links to resources for an absolute beginner to the SOAP authentication.
Thanks. P.S some of the links/credentials in the above could have been xxx'd for privacy.
If you have the SOAP extension enabled in php (php version >= 5.0.1), you can use the SoapClient class to process your request. To authenticate, you can pass the username and password to the class with the target URL:
$soapURL = "https://www.example.com/soapapi.asmx?wsdl" ;
$soapParameters = Array('login' => "myusername", 'password' => "mypassword") ;
$soapFunction = "someFunction" ;
$soapFunctionParameters = Array('param1' => 42, 'param2' => "Search") ;
$soapClient = new SoapClient($soapURL, $soapParameters);
$soapResult = $soapClient->__soapCall($soapFunction, $soapFunctionParameters) ;
if(is_array($soapResult) && isset($soapResult['someFunctionResult'])) {
// Process result.
} else {
// Unexpected result
if(function_exists("debug_message")) {
debug_message("Unexpected soapResult for {$soapFunction}: ".print_r($soapResult, TRUE)) ;
}
}
If you're not sure about the functions you can call, you can view the target URL (e.g. ending in ".asmx?wsdl") in your browser. You should get an XML response that tells you the available SOAP functions you can call, and the expected parameters of those functions.
Check out the soap_wsse library

Categories