I use Onesignal notifications for the app.
I don't have a problem sending the notifications but wanted to send these notifications using API help and this library.
php-onesignal library
The notifications I sent must be opened on the relevant page in the application. For this reason, I do not know how to write the URL in the code section below.
require_once(dirname(__FILE__).'/vendor/autoload.php');
use CWG\OneSignal\OneSignal;
$appID = '92b9c6bb-89d2-4cbc-8862-a80e4e81a251';
$authorizationRestApiKey = 'MWRjMTg2MjEtNTBmYS00ODA4LWE1M2EtM2YyZjU5ZmRkNGQ5';
$deviceID = '69aeecc1-7b58-44d1-8000-7767de437adf';
$api = new OneSignal($appID, $authorizationRestApiKey);
$retorno = $api->notification->setBody('Ola')
->setTitle('Titulo')
->addDevice($deviceID)
->send();
I entered the addTag section as in the Onesignal panel, but I could not run it.
$retorno = $api->notification->setBody('Ola')
->setTitle('Titulo')
->addTag('url', 'http://www.example.com/news/testtitle')
->send();
print_r($retorno);
How can I use it here in the Url section of the "ADDITIONAL DATA" field?
Can I solve this problem with addTag?
The following will send a notification with the $data['data'] as additional, as you want.
$data = [
'headings' => ['en' => 'Case 123'],
'contents' => ['en' => 'Case assigned ' . date('d-m-Y H:i')],
'data' => [
'type' => 'new',
'user_id' => 123,
'url' => 'http://www.example.com/news/testtitle'
],
];
OneSignal::sendNotificationCustom([
'app_id' => 1234,
'api_key' => abcd,
'included_segments' => ['All'],
'headings' => $data['headings'],
'contents' => $data['contents'],
'data' => $data['data'],
]);
Related
Notifications are sent, no problem mais I wish to have a badge on the notifications it is never used, I went through all the firebase documentation nothing to do. As is the keyword field.
Package used : edujugon/push-notification:4.5
$devices[] = $deviceData['id'];
$push = new PushNotification('fcm');
$push->setMessage([
'notification' => [
'title' => $this->title,
'body' => $this->body,
'badge' => $this->badge,
],
])
->setApiKey($this->apiKeyFirebase)
->setDevicesToken($devices)
->send();
With this array sent, I am not receiving the notification under IOS, so the feedback from the ios server tells me that the notification has been sent, there must be a problem with the keys to my array that I am sending, I don’t haven't found, would anyone know?
$devices[] = $deviceData['id'];
$push = new PushNotification('apn');
$push->setMessage([
'aps' => [
'alert' => [
'title' => $this->title,
'body' => $this->body,
],
'badge' => $this->badge,
],
])
->setConfig($this->getConfig())
->setDevicesToken($devices)
->send();
Yes, the feedback :
object(stdClass)#157 (3) {
["success"]=>
int(1)
["failure"]=>
int(0)
["tokenFailList"]=>
array(0) {
}
}
It tells me sucess true but i am not getting the notification on ios, it is not visible
With the library sly/notification-pusher, i received push notif ios but i have not title :(
$messages = [$this->body];
$params = ['title' => $this->title];
$pushNotificationService = new ApnsPushService(
$certificatePath, $passPhrase, PushManager::ENVIRONMENT_PROD
);
$response = $pushNotificationService->push($devices, $messages, [
'aps' => [
'alert' => [
'title' => $this->title,
'body' => $this->body,
],
'badge' => $this->badge,
]
]);
I am trying to create an Ticket via PHP & the REST genericinterface from OTRS (https://doc.otrs.com/doc/manual/admin/6.0/en/html/genericinterface.html#id-1.6.12.10.7.2).
I can create an Ticket and also an Article. But instead of an outgoing email the OTRS History looks like the user was sending a ticket to the queue. And also no mail is going out to the customer :-(.
But I like to have an outgoing EMail Ticket together with a pending state of the ticket.
Here my PHP code
<?php
header("Content-type: application/json; charset=utf-8");
require __DIR__ . '/vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client(['base_uri' => 'http://test-otrs.company.local/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/']);
$arrTicket = array(
"Title" => 'some ticket title',
"Queue" => 'testqueue',
"Lock" => 'unlock',
"Type" => 'Unclassified',
"State" => 'new',
"Priority" => '3 normal',
"Owner" => 'username',
"CustomerUser" => 'user#test.com'
);
$arrArticle = array(
"CommunicationChannel" => 'Email',
"SenderType" => 'agent',
"To" => 'user#test.com',
"Subject" => 'some subject',
"Body" => 'some body',
"ContentType" => 'text/plain; charset=utf8'
);
$response = $client->post('Ticket', ['json' => array("UserLogin" => "username", "Password" => "testtesttest", "Ticket" => $arrTicket, "Article" => $arrArticle)]);
if ($response->getBody())
{
echo $response->getBody();
}
https://forums.otterhub.org/viewtopic.php?p=168025#p168025 solved my problem. You need a extra plugin (https://github.com/znuny/Znuny4OTRS-GIArticleSend) to be able to send an outgoing EMail Ticket.
My scenario would be this flow in my application: Register > Sign Document > Return to Finish Page.
The user register on my application and he need to sign a document to finish his registration. He is not a DocuSign user. At the moment all my tests are at the Sandbox environment.
The envelope creation works great. If I don't use the client_user_id it sends the email for signing. But I need to use the client_user_id to use the embedded signing and get the URL for next step.
When I try to to get the URL of the envelope, I receive the following error:
errorCode: SHARED_VIEW_USER_LACKS_PERMISSION
message: User lacks shared permission to envelope. Only a user with shared access to the envelope may perform the requested operation.
Here is the code I'm using on my PHP application to try to get the URL of the recent created envelope:
$envelope = $this->docusignlib->create_document_for_signing($user, $file);
$result = $this->docusignlib->get_url_document($user, $envelope['envelope_id'], $return_url);
public function create_document_for_signing($user, $file)
{
# Document
$document = new DocuSign\eSign\Model\Document([
'document_base64' => base64_encode(file_get_contents($file)),
'name' => 'Document name',
'file_extension' => 'pdf',
'document_id' => '1'
]);
# Sign Here Position
$signHere = new DocuSign\eSign\Model\SignHere([
'document_id' => '1', 'page_number' => '2', 'recipient_id' => '1',
'tab_label' => 'Sign here', 'x_position' => '100', 'y_position' => '720'
]);
# The signer object
$signer = new DocuSign\eSign\Model\Signer([
'email' => $user->user_email,
'name' => $user->user_name,
'recipient_id' => "1",
'client_user_id' => $user->user_id,
'tabs' => new DocuSign\eSign\Model\Tabs([
'sign_here_tabs' => [$signHere]
])
]);
# Next, create the top level envelope definition and populate it.
$envelopeDefinition = new DocuSign\eSign\Model\EnvelopeDefinition([
'email_subject' => "Email subject",
'documents' => [$document],
'recipients' => new DocuSign\eSign\Model\Recipients(['signers' => [$signer]]),
'status' => "sent"
]);
$config = new DocuSign\eSign\Configuration();
$config->setHost($this->api);
$config->addDefaultHeader("Authorization", "Bearer " . $this->accessToken);
$apiClient = new DocuSign\eSign\Client\ApiClient($config);
$envelopeApi = new DocuSign\eSign\Api\EnvelopesApi($apiClient);
return $envelopeApi->createEnvelope($this->accountId, $envelopeDefinition);
}
public function get_url_document($user, $envelopeId, $returnUrl)
{
$recipientViewRequest = new DocuSign\eSign\Model\RecipientViewRequest([
'user_name' => $user->user_name,
'email' => $user->user_email,
"recipient_id" => "1",
"client_user_id" => $user->user_id,
"authentication_method" => "email",
"return_url" => $returnUrl
]);
$config = new DocuSign\eSign\Configuration();
$config->setHost($this->api);
$config->addDefaultHeader("Authorization", "Bearer " . $this->accessToken);
$apiClient = new DocuSign\eSign\Client\ApiClient($config);
$envelopeApi = new DocuSign\eSign\Api\EnvelopesApi($apiClient);
return $envelopeApi->createEnvelopeRecipientSharedView($this->accountId, $envelopeId, $recipientViewRequest);
}
I couldn't find ANYTHING related to this error on the documentation and I checked all the permissions and everything seems ok. I'm using the admin user of my demoaccount. Any ideas what I'm doing wrong here?
Thanks!
SHARED_VIEW_USER_LACKS_PERMISSION is about the user and the account. You may want to try a different account and/or a new envelope. I would also ensure that you are making API call to demo.docusign.net URL and not www.docusign.net since you are still in demo/sandbox.
The accessToken should match the account and if you're using the token generator, it's the account that you used when token generator prompted you to log in.
The following code subscribes to an SNS HTTP Endpoint:
$protocol = 'http';
$endpoint = 'http://test.com/endpoint.php';
$filterPolicyTest = array(
'test' => ['1','2','3']
);
$filterPolicyString = json_encode($filterPolicyTest);
$result = $this->awsClient->subscribe([
'Protocol' => $protocol,
'Endpoint' => $endpoint,
'ReturnSubscriptionArn' => true,
'TopicArn' => 'myTopicARN',
'Attributes' => [
'FilterPolicy' => $filterPolicyString,
],
]);
After confirming the subscription, I can view the subscription in the AWS console and see the Filter policy.
Now I try the same thing but with an email:
$protocol = 'email';
$endpoint = 'myemail#gmail.com';
$filterPolicyTest = array(
'test' => ['1','2','3']
);
$filterPolicyString = json_encode($filterPolicyTest);
$result = $this->awsClient->subscribe([
'Protocol' => $protocol,
'Endpoint' => $endpoint,
'ReturnSubscriptionArn' => true,
'TopicArn' => 'myTopicARN',
'Attributes' => [
'FilterPolicy' => $filterPolicyString,
],
]);
No errors are thrown. I successfully receive a confirmation email and click the link to subscribe. But, in the AWS console for this subscription, I see:
The FilterPolicy attribute is completely ignored.
I am using the PHP SDK version 3. Here is the documentation for this request. I tried submitting a FilterPolicy both as an array and json encoded string with no luck.
I have test-driving for Mailchimp API v3 using your PHP wrapper. It's working great for me But when I'm creating a request using POST for "Create Segment" getting an error (attach screenshot):
Request Code is (through associative array) -
$api_key = "xxxxxxxxxxxxxxxx-us11";
$list_id = "1xx2xx3xx4xx";
$MailChimp = new MailChimp($api_key);
$result = $MailChimp->post('lists/' . $list_id . '/segments', array('name' => 'Testing Data',
'options' => array('match' => 'all',
'conditions' => array('field' => 'type', 'op' => 'is', 'value' => 'Testing'))
));
This request call returning following error -
array (size=2) 'field' => string 'options.conditions' (length=18)
'message' => string 'Schema describes array, object found instead'
(length=44)
I will also tried to create Request (through associative array) -
Method 1:
$api_key = "xxxxxxxxxxxxxxxx-us11";
$list_id = "1xx2xx3xx4xx";
$MailChimp = new MailChimp($api_key);
$result = $MailChimp->post('lists/' . $list_id . '/segments', array('name' => 'Testing Data',
'options' => array('match' => 'all',
'conditions' => array(array('field' => 'type', 'op' => 'is', 'value' => 'Testing')))
));
Method 2:
$api_key = "xxxxxxxxxxxxxxxx-us11";
$list_id = "1xx2xx3xx4xx";
$MailChimp = new MailChimp($api_key);
$result = $MailChimp->post('lists/' . $list_id . '/segments', array('name' => 'Testing Data 4',
'options' => array('match' => 'all',
'conditions' => array(array('field' => 'type'), array('op' => 'is'), array('value' => 'Testing')))
));
Both method will create segment on mailchimp account but not have any conditions. See screenshot -
How to override this problem?
You are missing the condition_type param. It should be selected from the list provided by MailChimp in the endpoint documentation.
For example, IF the field "type" from your MailChimp list is a text field you should use 'condition_type': 'TextMerge'. In this case, conditions should have the following format:
[
{
'condition_type': 'TextMerge',
'field': 'type',
'op': 'is',
'value': 'Testing'
}
]
However, MailChimp MAY have a bug in this endpoint, since TextMerge works only on the EMAIL field. I have also stumbled upon this problem recently:
Mailchimp api v3 - can't create segment based on a TEXT merge field
https://github.com/drewm/mailchimp-api/issues/160