Activecollab Self Hosted account API Authentication invalid response - php

I am using this API integration https://github.com/activecollab/activecollab-feather-sdk
I using this below code to get token:
$authenticator = new \ActiveCollab\SDK\Authenticator\SelfHosted('<COMPANY NAME>', 'My Application', '<EMAIL>', '<PASSWORD>', 'http://criticalproject.com.mx/projects');
$token = $authenticator->issueToken();
// Did we get what we asked for?
if ($token instanceof \ActiveCollab\SDK\TokenInterface) {
print $token->getUrl() . "\n";
print $token->getToken() . "\n";
} else {
print "Invalid response\n";
die();
}
But I am getting
"invalid response".
Please check attachment for the error screenshot and suggest me
Below is the screen shot.
Note: i used dummy company name , application name. But email and password were correct. will that be an issue ?
If it is then how can i get the company name and application name, please suggest

Related

Why has DocuSign EventNotification stopped working?

In 2017 I integrated DocuSign with a website using the Official DocuSign PHP Client (https://github.com/docusign/docusign-php-client).
I took the example code and modified it so that it registered an EventNotification which would call back to the website once the signing process is complete. Code below.
require_once('docusign-php-client/autoload.php');
$username = "XXXXX";
$password = "XXXXX";
$integrator_key = "XXXXX";
// change to production (www.docusign.net) before going live
$host = "https://www.docusign.net/restapi";
// create configuration object and configure custom auth header
$config = new DocuSign\eSign\Configuration();
$config->setHost($host);
$config->addDefaultHeader("X-DocuSign-Authentication", "{\"Username\":\"" . $username . "\",\"Password\":\"" . $password . "\",\"IntegratorKey\":\"" . $integrator_key . "\"}");
// instantiate a new docusign api client
$apiClient = new DocuSign\eSign\Client\ApiClient($config);
$accountId = null;
try {
//*** STEP 1 - Login API: get first Account ID and baseURL
$authenticationApi = new DocuSign\eSign\Api\AuthenticationApi($apiClient);
$options = new \DocuSign\eSign\Api\AuthenticationApi\LoginOptions();
$loginInformation = $authenticationApi->login($options);
if (isset($loginInformation) && count($loginInformation) > 0) {
$loginAccount = $loginInformation->getLoginAccounts()[0];
$host = $loginAccount->getBaseUrl();
$host = explode("/v2", $host);
$host = $host[0];
// UPDATE configuration object
$config->setHost($host);
// instantiate a NEW docusign api client (that has the correct baseUrl/host)
$apiClient = new DocuSign\eSign\Client\ApiClient($config);
if (isset($loginInformation)) {
$accountId = $loginAccount->getAccountId();
if (!empty($accountId)) {
//*** STEP 2 - Signature Request from a Template
// create envelope call is available in the EnvelopesApi
$envelopeApi = new DocuSign\eSign\Api\EnvelopesApi($apiClient);
// assign recipient to template role by setting name, email, and role name. Note that the
// template role name must match the placeholder role name saved in your account template.
$templateRole = new DocuSign\eSign\Model\TemplateRole();
$templateRole->setEmail($vars['client_email']['value']);
//$templateRole->setEmail("robbielewis#me.com");
$templateRole->setName($vars['client_name']['value']);
$templateRole->setRoleName("Signee");
// pre-populate text tabs
$tabFields = array();
foreach ($vars as $var) {
$tabField = new \DocuSign\eSign\Model\Text();
$tabField->setTabLabel($var['label']);
$tabField->setValue($var['value']);
$tabFields[] = $tabField;
}
$tabs = new DocuSign\eSign\Model\Tabs();
$tabs->setTextTabs($tabFields);
$templateRole->setTabs($tabs);
// create event notification webhook
$envelope_events = [
(new \DocuSign\eSign\Model\EnvelopeEvent())->setEnvelopeEventStatusCode("sent"),
(new \DocuSign\eSign\Model\EnvelopeEvent())->setEnvelopeEventStatusCode("delivered"),
(new \DocuSign\eSign\Model\EnvelopeEvent())->setEnvelopeEventStatusCode("completed"),
(new \DocuSign\eSign\Model\EnvelopeEvent())->setEnvelopeEventStatusCode("declined"),
(new \DocuSign\eSign\Model\EnvelopeEvent())->setEnvelopeEventStatusCode("voided"),
(new \DocuSign\eSign\Model\EnvelopeEvent())->setEnvelopeEventStatusCode("sent"),
(new \DocuSign\eSign\Model\EnvelopeEvent())->setEnvelopeEventStatusCode("sent")
];
$recipient_events = [
(new \DocuSign\eSign\Model\RecipientEvent())->setRecipientEventStatusCode("Sent"),
(new \DocuSign\eSign\Model\RecipientEvent())->setRecipientEventStatusCode("Delivered"),
(new \DocuSign\eSign\Model\RecipientEvent())->setRecipientEventStatusCode("Completed"),
(new \DocuSign\eSign\Model\RecipientEvent())->setRecipientEventStatusCode("Declined"),
(new \DocuSign\eSign\Model\RecipientEvent())->setRecipientEventStatusCode("AuthenticationFailed"),
(new \DocuSign\eSign\Model\RecipientEvent())->setRecipientEventStatusCode("AutoResponded")
];
$event_notification = new \DocuSign\eSign\Model\EventNotification();
$event_notification->setUrl("https://www.XXXXX.com/wp-content/plugins/XXXXX/XXXXX.php?action=docusign-callback");
$event_notification->setLoggingEnabled("true");
$event_notification->setRequireAcknowledgment("true");
$event_notification->setUseSoapInterface("false");
$event_notification->setIncludeCertificateWithSoap("false");
$event_notification->setSignMessageWithX509Cert("false");
$event_notification->setIncludeDocuments("true");
$event_notification->setIncludeEnvelopeVoidReason("true");
$event_notification->setIncludeTimeZone("true");
$event_notification->setIncludeSenderAccountAsCustomField("true");
$event_notification->setIncludeDocumentFields("true");
$event_notification->setIncludeCertificateOfCompletion("true");
$event_notification->setEnvelopeEvents($envelope_events);
$event_notification->setRecipientEvents($recipient_events);
// instantiate a new envelope object and configure settings
$envelop_definition = new DocuSign\eSign\Model\EnvelopeDefinition();
$envelop_definition->setEmailSubject("Please review and sign your booking contract");
$envelop_definition->setTemplateId("XXXXX");
$envelop_definition->setTemplateRoles(array($templateRole));
$envelop_definition->setEventNotification($event_notification);
// set envelope status to "sent" to immediately send the signature request
$envelop_definition->setStatus("sent");
// optional envelope parameters
$options = new \DocuSign\eSign\Api\EnvelopesApi\CreateEnvelopeOptions();
$options->setCdseMode(null);
$options->setMergeRolesOnDraft(null);
// create and send the envelope (aka signature request)
$envelop_summary = $envelopeApi->createEnvelope($accountId, $envelop_definition, $options);
if (!empty($envelop_summary)) {
echo "Contract sent at " . date('d/m/Y H:i:s') .' to '.$templateRole->getEmail();
}
}
}
}
} catch (DocuSign\eSign\ApiException $ex) {
echo "Exception: " . $ex->getMessage() . "\n";
file_put_contents('XXXXX.log', "\n\n" . date('d/m/Y H:i:s') . ' - Docusign API error ' . $ex->getMessage(), FILE_APPEND);
wp_mail('XXXXX', 'Docusign API error', date('d/m/Y H:i:s') . ' - Docusign API error: ' . $ex->getMessage());
}
This worked fine for a couple of years until recently we stopped getting the EventNotification request to our server from Docusign when the envelope is signed. The envelope is still created successfully and sent to the recipient.
Things I have tried to resolve the issue:
Created many test envelopes using my script and signed them
Monitored the access logs on the server for any http requests following the signing of an envelope that was created by the script, nothing received
Updated the DocuSign PHP Client to the latest version
Enabled logging in DocuSign and checked that the EventNotification request is being received by DocuSign when the envelope is created, see here: https://pastebin.com/xbS338Hx
Contacted my host to ensure that there is no hardware firewall that could be preventing the server receiving HTTP requests from DocuSign
Turned off Cloudflare DNS proxy to make sure that it isn't blocking the request to the server
Contacted DocuSign Support who said to post here as they cannot provide assistance with code issues.
What else can I try to pinpoint the cause of this issue?
Using DocuSign Connect Failures screen in DocuSign Admin I was able to see failed connections in the list.
https://www.XXXXX.com/wp-content/plugins/sXXXXX/XXXXX.php?action=docusign-callback :: Error - The remote server returned an error: (403) Forbidden.
It turned out to be iThemes Security Plugin for Wordpress denying the requests. I disabled the plugin and republished the most recent failed request in DocuSign Admin. The request came through successfully.

send Message to a user by Username in telegram bot

I used php-telegram-bot/core to create a shopping bot in telegram.
What I want to do is when a User make an order, bot send a notification that a new Order is come to admin of Channel.
Suppose admin channel username is like #admin_username and stored in a global variable(means that may be change in a period of time). for that I wrote this :
static public function showOrderToConfirm ($order)
{
if ($order) {
Request::sendMessage([
'chat_id' => '#admin_username',
'text' => 'New Order registered',
'parse_mode' => 'HTML'
]);
}
}
But this does not work and does not anything.
Telegram bot API does not support sending messages using username because it's not a stable item and can be changed by the user. On the other hand, bots can only send messages to user that have sent at least one message to the bot before.
You know that when a user sends a message to a bot (for example the users taps on the start button) the bot can get his/her username and ChatID (As you know ChatID is different from username; ChatID is a long number) so I think the best way that you can fix this issue is storing the chat IDs and related usernames in a database and send the message to that chatID of your favorite username.
By the way, try searching online to see whether there is an API which supports sending messages to usernames or not. But as I know it's not possible.
This example works very well:
<?php
$token = 'YOUR_TOCKEN_HERE';
$website = 'https://api.telegram.org/bot' . $token;
$input = file_get_contents('php://input');
$update = json_decode($input, true);
$chatId = $update['message']['chat']['id'];
$message = $update['message']['text'];
switch ($message) {
case '/start':
$response = 'now bot is started';
sendMessage($chatId, $response);
break;
case '/info':
$response = 'Hi, i am #trecno_bot';
sendMessage($chatId, $response);
break;
default:
$response = 'Sorry, i can not understand you';
sendMessage($chatId, $response);
break;
}
function sendMessage($chatId, $response){
$url = $GLOBALS['website'] . '/sendMessage?chat_id=' . $chatId .
'&parse_mode=HTML&text=' . urlencode($response);
file_get_contents($url);
}
?>

Auto-renewable subscriptions for iOS: How to get Server-side receipt validation?

I just finish to developp my app, create my Apple organization account, create all I need on the iTunes connect side, but my problem now, is to develop the server-side receipt validation (because the Validating Receipts Locally seems to have some potential man in the middle security problems).
...
// Load the receipt from the app bundle.
NSURL *receiptURL = [[NSBundle mainBundle] appStoreReceiptURL];
NSData *receipt = [NSData dataWithContentsOfURL:receiptURL];
if (!receipt) { /* No local receipt -- handle the error. */ }
/* ... Send the receipt data to your server ... */
...
I well-understanded the process of the validation as described on that picture:
My main problem is I am not a big expert about server's question, and if you have some examples of what I have to code for the receipt verification and what technologie I have to use (PHP, Angular, or else...).
(First example: On that ticket, is the code on the server side is enough to accomplish that verification?)
(Second example: Is that process is good with the sending of the UDID and the receipt coded in Base64 to the server with a JSON, the server ask to the app store, the app store send ok, and the server send ok to the app. If it is the good process, I can do it easily. Ticket 2
Thanks in advance.
Here is my solution:
I use my server to validate my the receipt like this:
https://github.com/aporat/store-receipt-validator
use ReceiptValidator\iTunes\Validator as iTunesValidator;
$validator = new iTunesValidator(iTunesValidator::ENDPOINT_PRODUCTION); // Or iTunesValidator::ENDPOINT_SANDBOX if sandbox testing
$receiptBase64Data = 'ewoJ
......
OVG8xTlNCRmRHTXZSMDFVSWpzS2ZRPT0iOwoJImVudmlyb25tZW50IiA9ICJTYW5kYm94IjsKCSJwb2QiID0gIjEwMCI7Cgkic2lnbmluZy1zdGF0dXMiID0gIjAiOwp9';
try {
$response = $validator->setReceiptData($receiptBase64Data)->validate();
// $sharedSecret = '1234...'; // Generated in iTunes Connect's In-App Purchase menu
// $response = $validator->setSharedSecret($sharedSecret)->setReceiptData($receiptBase64Data)->validate(); // use setSharedSecret() if for recurring subscriptions
} catch (Exception $e) {
echo 'got error = ' . $e->getMessage() . PHP_EOL;
}
if ($response->isValid()) {
echo 'Receipt is valid.' . PHP_EOL;
echo 'Receipt data = ' . print_r($response->getReceipt()) . PHP_EOL;
} else {
echo 'Receipt is not valid.' . PHP_EOL;
echo 'Receipt result code = ' . $response->getResultCode() . PHP_EOL;
}
And the WS on my server send me okay or not.
(For the local process on the iPad which is not advisable, you can find it here : I'm getting 21004 as status value in reply from apple's sandbox server testing auto-renewable subscriptions in ios?)

How to preserve a hyperlink on Android SMS message

I am sending an SMS message to an Android phone using Twilio.
The domain has a hypen in it. e.g. http://my-domain.com
When the SMS message arrives on Android, only the initial portion of the text is included in the hyperlink.
So in the above example the hyperlink is "http://my"
How is it possible to escape a hyperlink being send to android? I am using the PHP Twilio client.
It might be you done any small mistake. And, it not depend on android or iOS.
I also tried and it worked as its not specific to Android or iOS.
<?php
require '../Services/Twilio.php'; // Include the Twilio PHP library
$version = "2010-04-01"; // Twilio REST API version
// Set our Account SID and AuthToken
$sid = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyy';
$token = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$client = new Services_Twilio($sid, $token, $version); //initialise the Twilio client
$message = 'http://my-domain.com';
try {
// Initiate a new outbound call
$call = $client->account->messages->create(array(
'To' => "+YYYYYYYYYY",
'From' => "+1XXXXXXXXXX",
'Body' => $message,
));
echo 'TWILIO SMS';
echo 'Sending.... ';
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
?>
Here, my code. From this am getting this url as same in SMS from Twilio.
You please check your code once. And, I hope my code will help you.

Error 403 when trying to Twitter "Send User to Authorization" step (PHP OAuth)

I have spent a ton of hours on this and cannot for the life of me figure out what the problem is here. I am writing my own twitter web app. I downloaded the OAuth PHP Library which is what I am using. Everything was setup correctly.
I did Step 1 and "Acquire a Request Token". I got a correct response back with a token, token secret and callback confirmed of TRUE.
Now I proceeded to the next step of "Send User to Authorization" and passed along the oauth_token parameter to the request. The request got sent and redirects to the Twitter page, but when it gets there is is showing an error message of :
Exception Request failed with code 403:
Woah there!
This page requires some information that was not provided. Please return to the site that sent you to this page and try again … it was probably an honest mistake.
What is the problem?? The error message is not very helpful. According to Twitter 403 means the request was understood but denied. I am really stuck here and would appreciate the help with this one.
Here is what the code looks like (I have obviously replaces my token and secret keys with ########, so if anyone wanted to test this locally with their own keys, just replace the ######### values:
<?php
include_once "scripts/OAuth/OAuthStore.php";
include_once "scripts/OAuth/OAuthRequester.php";
// register at http://twitter.com/oauth_clients and fill these two
define("TWITTER_CONSUMER_KEY", "#############");
define("TWITTER_CONSUMER_SECRET", "#############");
define("TWITTER_OAUTH_HOST","https://api.twitter.com");
define("TWITTER_REQUEST_TOKEN_URL", TWITTER_OAUTH_HOST . "/oauth/request_token");
define("TWITTER_AUTHORIZE_URL", TWITTER_OAUTH_HOST . "/oauth/authorize");
define("TWITTER_ACCESS_TOKEN_URL", TWITTER_OAUTH_HOST . "/oauth/access_token");
define("TWITTER_PUBLIC_TIMELINE_API", TWITTER_OAUTH_HOST . "/statuses/public_timeline.json");
define("TWITTER_UPDATE_STATUS_API", TWITTER_OAUTH_HOST . "/statuses/update.json");
define('OAUTH_TMP_DIR', function_exists('sys_get_temp_dir') ? sys_get_temp_dir() : realpath($_ENV["TMP"]));
// Twitter test
$options = array('consumer_key' => TWITTER_CONSUMER_KEY, 'consumer_secret' => TWITTER_CONSUMER_SECRET);
OAuthStore::instance("2Leg", $options);
try
{
// Obtain a request object for the request we want to make
$request = new OAuthRequester(TWITTER_REQUEST_TOKEN_URL, "POST");
$result = $request->doRequest(0);
parse_str($result['body'], $params);
list($token, $secret, $status) = explode('&', $result['body']);
// now make the request.
$request = new OAuthRequester(TWITTER_AUTHORIZE_URL, 'POST', $token);
$result = $request->doRequest();
}
catch(OAuthException2 $e)
{
echo "Exception " . $e->getMessage();
}
?>

Categories