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.
Related
I have a multidimensional array containing data from a form and I need this array in another Controller in the same controller to continue working with it, but I don't know how I do that.
The array can look like this example:
array [
"absender" => "Maxim Ivan",
"email" => "maximivan#example.com",
"telefon" => "1234567890",
"fax" => null,
"grund" => "Gehaltserhöhung",
"termin" => [
0 => [
"person" => "Some Name",
"meeting" => "10.05"
],
1 => [
"person" => "Another Name",
"meeting" => "18.05"
],
2 => [
"person" => "Again another name",
"next-possible-meeting" => "1"
],
3 => [
"person" => "And again",
"next-possible-meeting" => "1"
],
],
"bemerkung" => "some notes by Maxim"
]
This array is created(and the input data validated) in the store-method of the 'TerminController'.
This method will return a view where all of this data gets displayed again, to let the user check the info and can then add a document.
When the document is added and the data gets submitted with an input-button the upload-method in the same Controller gets called.
And there's where I need the array with the form-data to go on working with it.
But how do I achieve passing the array through to the next function that is only called with an input-button.
First approach was to save the array into the session, which did even work even though it was hard due to the multidimensional; but it's a really ugly solution.
Should I save the input data into a database in the store-method and fetch it again in the upload-method?
Or is it somehow possible to pass the array through the Controllers/ make it accessible in the upload-Controller even though it gets created in another one?
I have also heard something about using serialize()and unserialize(), but I'm not exactly sure how this could help me..
Or maybe there's another and even better solution I just don't think of?
I'd appreciate all the help I can get.
The array varies, it can be 17 arrays nested in 'termin' but I can also be just one.
You can store it in the cache:
Cache::put('multiArray', $multiArray); //put array in cache
$array = Cache::get('multiArray'); //retreive from cache
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
I'm looking for a way to create a new source for a customer and then set that source as the default source for the customer. The problem I'm currently facing is that the response from creating the source does not give me a easy way to identify the id for the new created source so that I can set that source as default.
Below is my code, without any API key and customer ID:
\Stripe\Stripe::setApiKey($stripe_api_key);
$customer = \Stripe\Customer::retrieve($_SESSION['parent']['stripe_customer_id']);
$customer->sources->create(array('source' => array("object" => "card", 'exp_month' => $expire_month, 'exp_year' => $expire_year, 'number' => $card_number, 'address_line1' => $billing_address1, 'address_line2' => $billing_address2, 'address_city' => $billing_city, 'address_zip' => $billing_postal_code, 'address_country' => $billing_country, 'currency' => 'GBP', 'cvc' => $security_code, 'name' => $_SESSION['parent']['firstname'] . ' ' . $_SESSION['parent']['lastname'])))->__toArray(true);
//set as default
if (isset($_POST['check_default_source'])) {
$customer->default_source=$customer['id'];
$customer->save();
}
I also had this problem, slightly different.
I added a new source from a token_id.
The getLastResponse method was not available in my API or library version.
But using the token object (Stripe::Token::retreive( token_id )) you can actually retrieve the card_id, and use that to update the default_source.
Took me a long time to figure this out, so I post it here. Maybe it helps someone in the future...
I was able to to find the solution to my question. Stripe API does send back the id of the source that was just created and to get the ID I use the below code:
$source_id = json_decode($customer->sources->getLastResponse()->body)->id;
When creating a client via the API, how do we assign the Client+ role to them and assign them to a project? I've created a script which redirects users to projects based on their email address.
The client is created, but I believe can only be assigned the role of Client (no client+ role exists). The additional client plus permissions come from custom permission: manage tasks, from what I can see in the database.
When I include this permission, the client is never created.
This is my code to create client:
$payload = [
"type" => "Client",
"first_name" => $first_name,
"last_name" => $last_name,
"email" => $email,
"password" => $this->rand_string(15),
"company_id" => $company,
];
$result = $this->client->post("/users", $payload);
$result_json = $result->getJson();
$client_id = #$result_json['single']['id'];
$payload = [
"id" => $project,
"members" => array(
$client_id
),
];
$result = $this->client->post("/projects", $payload);
The client gets created, although without the right permissions, and the client is never added to the project (which means they can't make a task against it).
Client+ is a regular Client instance, with extra permissions. These extra permissions are set using custom permissions property. Note that this works only if Client+ is enabled in Add-Ons section of the app.
Apparently, POST-ing to /users API breaks, but you can use regular invitation route and POST on /users/invite API end-point with this payload:
$payload = [
"role" => "Client",
"custom_permissions" => ["can_manage_tasks"],
"email_addresses" => [$email],
"company_id" => $company_id,
"project_ids" : [1, 2, 3],
];
to invite users with Client+ permissions.
I try to set a reminder (30 minutes before due date) on a task created by the API based on doc examples: https://developers.podio.com/doc/tasks/create-task-with-reference-22420
https://developers.podio.com/doc/tasks/create-task-22419
Here's the code:
PodioTask::create_for(
'item',
$order->item_id,
array(
'text' => "Préparer la livraison de la commande",
'description' => "Testing tasks",
'responsible' => 00000,
'due_date' => date('Y-m-d'),
'due_time' => '09:00:00',
'reminder' => array('remind_delta' => 30)
)
);
Beside of the fact that the reminder is not set, the task is created with the provided information above. There is no error related to the API.
Is there something missing?
I realize this is old, but I finally figured it out. See below:
PodioTask::create_for(
'item',
$item_id,
$attributes = array (
'text' => $item_id,
'private' => true,
'due_date' => $appt_date,
'due_time' => $appt_time,
'responsible' => 1234567, // User ID
'reminder' => (object)[
'remind_delta' => 0
]
)
);
For my purposes the user will always be the same, so I set that as static.
BE AWARE You MUST authenticate with the API using the users credentials that the reminder is being set for. It WILL NOT set a reminder for another user (partially why I'm using a static user).
EDIT Since I don't have enough reputation points, I want to call out Pavlo - Podio
One can verify if a reminder is set by looking at it in Podio. It's pretty simple, either there's a reminder set or there's not.
The OP, and myself, aren't using Ruby, so whether Ruby works or not is irrelevant to the problems we're facing.
While I realize you were trying to help. The fact that you're a "Test Automation Engineer at Podio" raises the expectation that you COULD provide useful information. So pull out the PHP and see what we're experiencing.