Trying to Stream music while connecting Nexmo NCCO - php

I tried to stream music while connecting the agent into the phone call.
but it's stuck in the stream and then calling.
anyone used it before? I'm sure that's impossible to make this.
Code:
$array[] = array(
"action" => "stream",
"streamUrl" => array("https://pbx.makeapp.co.il/wait.mp3"),
);
$array[] = array(
"action" => "connect",
"eventType" => "synchronous",
"eventUrl" => array("https://pbx.makeapp.co.il/config.json?step=1"),
"timeout" => 30,
"from" => "YOUR_NEXMO_PHONE",
"endpoint" => array(array(
"type" => "sip",
"uri" => "sip:your_sip#sip.antisip.com",
)
)
);

You are correct, it is not possible to have 2 actions running at the same time using an NCCO. When you add a stream action to the start of your NCCO, this must be completed before it moves onto the next action. An NCCO array is actioned from top to bottom, and only moves onto the next action when the current one has finished. You can find out some more info in the concepts of an NCCO section of the documentation: https://developer.nexmo.com/voice/voice-api/ncco-reference

Related

Architectural decision for asynchronous API requests for queue of dependent messages

I need to implement some script for exporting data from one service to another. Origin service has written using PHP language. Destination service has an SOAP API with MQ under the hood so every request to that API is converted into message which goes into queue and waiting to be processed. API server responses to this request only with message ID so I need to perform one or multiple extra request with that message ID as a param to get status and result of processing my initial request.
The main problem is that I have a lot of data to be processed where next request depends on the result of the previous request. I'm going to use some kind of MQ service on the client side to make client "to wait" for the result of the successful processing of the previous request. Currently there are 2 such services in our project's stack: Kafka and Gearman. It would be great to solve topic problem using these without requirement to set up some additional services.
Exporting data mainly will consist of hierarchical structures with folders and complex composite elements. For example, imagine some structure:
[
'title' => 'Cars',
'folders' => [
[
'title' => 'Chevrolet',
'folders' => [],
'files' => [
['file' => '/path/to/images/dir/camaro.jpg'],
['file' => '/path/to/images/dir/tahoe.jpg']
]
],
]
]
I have to reproduce exact structure on the destination service through API. So according to API's features I have to perform multiple requests:
// Ask API to create folder
>>> ['action' => 'create-folder', 'name' => 'Cars', 'parent' => 'null']
// Get ID of the message in queue
<<< ['status' => 'received', 'message-id' => 123]
// Request message status
>>> ['action' => 'get-message-result', 'message-id' => 123]
// Get ID of the created folder
<<< ['status' => 'created', 'folder-id' => 1]
// Perform next request using ID of created folder as parent ID
>>> ['action' => 'create-folder', 'name' => 'Chevrolet', 'parent' => 1]
<<< ['status' => 'received', 'message-id' => 124]
>>> ['action' => 'get-message-result', 'message-id' => 124]
<<< ['status' => 'pending']
// ... Maybe rerun request multiple times because of server delays
>>> ['action' => 'get-message-result', 'message-id' => 124]
<<< ['status' => 'created', 'folder-id' => 2]
// Upload physical file
>>> ['action' => 'upload-file', 'path' => '/path/to/images/dir/camaro.jpg']
<<< ['status' => 'received', 'message-id' => 125],
>>> ['action' => 'get-message-result', 'message-id' => 125]
// Get path to the uploaded file, generated by server
<<< ['status' => 'created', 'file-name' => '/tmp/_190402934.jpg'],
// Create DB record linked to that physical file
>>> ['action' => 'create-file', 'path' => '/tmp/_190402934.jpg'],
<<< ['status' => 'received', 'message-id' => 126],
>>> ['action' => 'get-message-result', 'message-id' => 126]
<<< ['status' => 'created', 'file-id' => 100],
// ... and so on
The main thing that I want to show is that one request is dependent on another. Result of request does not contain data about success, only ID of message in queue so to get result data it is required to perform unknown number of extra requests after main. And only after receiving of required data (e.g. ID of created folder) client's queue can go to the next step.
Could you help me with your suggestions with effective way to implement this? Whether it possible to implement using Gearman or/and Kafka?
Whether it is possible to set some constraint on client's MQ which will restrict service to start next API request only after receiving required result of previous request (regardless of delay and number of 'get-message-result' extra requests between main request and actual result of processing that request)?
Maybe you could suggest some examples, articles or books where similar problems were solved?

Ionic Firebase push notification icon is not visible on all devices

I have an Ionic app (v 2.0.2) consisting Firebase Push notification. I am having some issues. Stating them here.
I am getting the Notification Icon to appear on Xiaomi device but can not get it to show on Samsung. I have used following php code
$message_for_push = array(
"data" => array(
"title" => "New Content Published!",
"body" => $message['title'],
"icon" => "file://assets/img/firebase_push_icon.png", //also tried "icon" => "myicon",
"color" => "#e81010",
'sound' => 'mySound',
"type" => $message['type'],
"section_id" => $message['section_id'],
"isPush" => 1,
"subdomain" => $subdomain, //dynamiic
"id" => $message['id'],
"other_key" => true
),
"registration_ids" => $registrationIds
);
it takes the default icon (not transparent) on Xiaomi but not on Samsung.
I have generated the icons from http://romannurik.github.io/AndroidAssetStudio/icons-notification.html#source.type=clipart&source.clipart=ac_unit&source.space.trim=1&source.space.pad=0&name=ic_stat_ac_unit and put all in mipmap-* folders having name firebase_push_icon.png.
I have also tried with the transparent Icon, does not work either. (I found that I have to provide transparent icon)
Only shows a round circle.
My questions are
where should I put the transparent Icon?
what should be the file name of the Icon?
what should I put on "icon" in php end?
When I use both data and notification, I get two notification, why is this?
Thanks in advance.

Edit Mikrotik User Profile With PHP API

I'm building a WiFi authentication tool with user profile edit and guest credentials, etc.
I can write users to the mikrotik and remove users without an issue, but I can't find any documentation on editing the user profile. I suppose I could just remove it and add a new record, but that is just inefficient and may create issues with user keys down the line.
I'm using class.routeros_api.php and I'm on version 6.30
To add a user is done like so...
$response = $api->comm("/tool/user-manager/user/add",array(
"customer" => "admin",
"username" => "guest_user",
"location" => "Guest",
"first-name" => "Guest",
"last-name" => "1",
"password" => "somepw",
"shared-users" => "1",
"copy-from" => "00:00:00:00:00:00"
));
Deleting a user...
$response = $api->comm("/tool/user-manager/user/remove",array(
".id" => "*15"
));
so I figured editing a user would be something like...
$response = $api->comm("/tool/user-manager/user/edit",array(
".id" => "*15",
"username" => "someotheruser",
"password" => "someotherpass"
));
However, the error I'm receiving is...
<<< [28] /tool/user-manager/user/edit
<<< [8] =.id=*14
<<< [14] =username=someotheruser
<<< [19] =password=someotherpass
>>> [5/5] bytes read.
>>> [5, 35]!trap
>>> [26/26] bytes read.
>>> [26, 8]=message=unknown parameter
>>> [5/5] bytes read.
>>> [5, 1]!done
If someone has done this before and can assist with the appropriate syntax for the "/tool/user-manager/user/edit" command, it would be greatly appreciated.
So after some research into how this thing actually works, it appears I was just using the wrong command.
The correct way to edit a user on the mikrotik is to do the following...
$api->comm("/tool/user-manager/user/set",array(
".id" => "*14",
"username" => "somenewuser"
"password" => "somenewpassword",
));
In fact, "set" is the way you post edits for every feature. "edit" is for multi-line editing.
Special thanks to drew010 for the WinBox idea and the link to the commands wiki.

Elasticsearch Completion

I have a elasticsearch index which i update every 10 minutes via cronjob. In this index i have a completion field which works as expected.
But i have one little problem. Lets say i have a "article" field where i change a value from "a" to "b". After 10 minutes the index is been updated and the document which holds article "a" is been updated to article "b". Everything as expected.
But my completion field now holds both values. "a" and "b" both with the same id.
How can this happen?
Mapping:
'suggest' => array(
'type' => 'completion',
'payloads' => true,
'preserve_separators' => false,
'search_analyzer' => 'standard',
'index_analyzer' => 'standard'
),
How i set the field:
'suggest' => array(
'input' => array(
$result["Name"],
$result["Name"],
$result["Name2"],
$result["Name3"],
$result["Name4"],
$result["Name5"]
),
'output' => $result["Name"].' (' . $result["Name1"].', '.$result["Name2"].')',
'payload' => array(
'id' => $result["ID"]
)
)
Found the answer in the docs.
The suggest data structure might not reflect deletes on documents immediately. You may need to do an Optimize for that. You can call optimize with the only_expunge_deletes=true to only cater for deletes or alternatively call a Merge operation.

ChargeBee - PHP create subscription breaks PHP loading the page

Working on a Chargebee integration, using their suggest PHP library.
I have the include statement at the top of the page, to include the library.
And I set the environment variables with test server information copy-pasted from the control panel.
No matter what I try, when I use their sample code, my page load breaks and I get a white screen. Without this block of code, the page loads fine and all dbase calls works perfectly.
Is there more to know about the Chargebee library that I'm not catching?
(in the top of the php)
include("/app/includes/chargebee-php-master/lib/ChargeBee.php");
ChargeBee_Environment::configure("SERVERNAME-test",
"test_KEYFROMCONTROLPANEL");
(inline code in a function)
$result = ChargeBee_Subscription::create(array(
"planId" => "pond_ripple",
"customer" => array(
"email" => "john#user.com",
"firstName" => "John",
"lastName" => "Doe",
"phone" => "+1-949-999-9999"
),
"billing_address" => array(
"firstName" => "John",
"lastName" => "Doe",
"line1" => "PO Box 9999",
"city" => "Walnut",
"state" => "CA",
"zip" => "91789",
"country" => "US"
)
));
$subscription = $result->subscription();
$customer = $result->customer();
$card = $result->card();
$invoice = $result->invoice();
$sampleString = $customer["id"];
Is your include path correct?
include("/app/includes/chargebee-php-master/lib/ChargeBee.php");
Can you crosscheck whether it starts from a base directory? ie. /app/includes/chargebee-php-master/lib/ChargeBee.php or is it relative? i.e app/includes/chargebee-php-master/lib/ChargeBee.php
If your path is right (full path), can you provide the error log to debug further? Also you need to access ChargeBee customer object as $customer->id and not as an array.

Categories