Firebase Realtime Queries with indexes In php - php

I am facing an issue while applying queries on firebase data in PHP.
I want to get online users list from the above offline and online data
that is stored in firebase
actually under user_list I have added user's ids that is dynamic/variables so I can't apply rule on the behalf of this.
[
user_list=>[1 => ['id' => 1, 'name' => 'abbas', 'status' => 'online'], 2 => ['id' => 2, 'naumani' => '1.0,2.0', 'status' => 'online'], 3 => ['id' => 3, 'dev' => '1.0,2.0', 'status' => 'offline'], 4 => ['id' => 4, 'dev' => '1.0,2.0', 'status' => 'offline']]
]

I found the solutions from the documentations:
https://firebase.google.com/docs/database/security/indexing-data#section-indexing-order-by-value
The example of dinosaurs was very helpful for me.
Steps:
set the rule first:
Then in Admin SDK use orderByChild (Mine is PHP)

Related

Get IDs of benchmark accounts

I'm creating a web app where I need to get the id's of the accounts that will act as benchmark accounts, at the moment what I thought is to have a separate file called bench-accounts where I'll be able to get the id and the color of each account. Then I use config('bench-accounts') to be able to get the accounts and filter them as I want. I did it this way because whoever manages this will be able to get the id of the account from the database then add it here and have it act as a benchmark account (since I think it will be the best way for people that doesn't have a lot of knowledge with programming)
The file would follow the next structure:
<?php
return [
1 => [
'id' => 1,
'color' => '#00cfff',
],
2 => [
'id' => 2,
'color' => '#ff0000',
],
130 => [
'id' => 130,
'color' => '#fff200',
],
149 => [
'id' => 149,
'color' => '#3F220F',
],
168 => [
'id' => 168,
'color' => '#00ff0f',
],
169 => [
'id' => 169,
'color' => '#5438DC',
],
170 => [
'id' => 170,
'color' => '#3E517A',
]
];
Is it correct? I'm planning on adding an active parameter so that in the future you'll be able to activate or disable it on which accounts you want to benchmark and which not.
Tried it adding the account to a config file where it will have different parameters and the ids of the accounts.

Using Guzzle with GetResponse API to save custom field?

I am sending a post request to the GetResponse API. Everything works fine until I add a custom field (customFieldValues) to save along with my new email contact.
$body_data =
[
'name' => $input['name'],
'email' => $input['email'],
'campaign' => [
'campaignId' => $campaign_id
],
'customFieldValues' => ['customFieldId' => 'LDe0h', 'value' => ['Save this test string.'] ]
];
When I send the request I get the following error message:
"errorDescription": "CustomFieldValue entry must be specified as array"
I have tried a few things now and not sure how to format this properly to have the API accept it.
Reference link:
http://apidocs.getresponse.com/v3/case-study/adding-contacts
I found the solution on github in an example for their php api here:
https://github.com/GetResponse/getresponse-api-php
I suppose I had to wrap an array inside an array inside of an array...geez:
'customFieldValues' => array(
array('customFieldId' => 'custom_field_id_obtained_by_API',
'value' => array(
'Y'
)),
array('customFieldId' => 'custom_field_id_obtained_by_API',
'value' => array(
'Y'
))
)
For GetResponse V3
'customFieldValues' => [
'customFieldId' => 'custom_field_id_from_API',
'name' => 'Website',
'value' => ['https://scholarshipspsy.com']
]
Please note the 'name' field is optional. The site sampled is an international scholarship platform.

PushWoosh - Location based notifications via Remote API

I am looking to filter notifications based on users current location. I get that I can set geozones through the PushWoosh web-site, but I can't seem to find any way to do this through the remote API.
I want to do something like this:
$this->pwCall('createMessage',
array
(
'application' => 'XXXXX-XXXXX',
'auth' => 'XXXXXX[...]',
'lng' => 42,
'lat' => 42,
'range' => 1000,
'notifications' => array
(
array
(
"platforms" => array(3),
'send_date' => 'now',
"ignore_user_timezone" => true,
'content' => "$message",
'data' => array("type" => $type),
"android_header" => "$header",
)
)
)
);
In other words: Send the notification to any device within a certain range from a specific location, but I can't get it to work. Is it even possible to do something like this?
Thank you in advance!

SkaDate admin panel lock

I have installed SkaDate, but it's creating auth.php creating error. I am getting the error:
bruce attack account is locked.
Its having auth.php file for validating login details.
Although in MySQL database value for admin username and password same I enter then also getting this error.
SkaDate is a dating software package.
To remove this notification, go through $internal_c/lang/config.php file
find the code around line number 7469 this code looks something similar to this.
'try_number' =>
SK_ConfigDtoObject::__set_state(array(
'config_id' => '208',
'config_section_id' => '63',
'name' => 'try_number',
'value' => 5,
'presentation' => 'integer',
'description' => NULL,
'php_validation' => NULL,
'js_validation' => NULL,
)),
Here, set the value to zero, like
'try_number' =>
SK_ConfigDtoObject::__set_state(array(
'config_id' => '208',
'config_section_id' => '63',
'name' => 'try_number',
'value' => 0,
'presentation' => 'integer',
'description' => NULL,
'php_validation' => NULL,
'js_validation' => NULL,
)),
Also set the lock_stamp attribute to zero, like
'lock_stamp' =>
SK_ConfigDtoObject::__set_state(array(
'config_id' => '206',
'config_section_id' => '63',
'name' => 'lock_stamp',
'value' => 0,
'presentation' => 'integer',
'description' => NULL,
'php_validation' => NULL,
'js_validation' => NULL,
)
And the last step is, in the config table, search the config_section_id (here it's 63, see above code) and change the values of 'try_number' and 'lock_stamp' attributes to zero.
This should solve your problem....
I can't locate you in our database, so please let me know your Client IDs in SkaDate system. We are more than happy to help you with any issues we'll be glad to answer any of your questions. Just visit www.skadate.com and drop us a line.

CakePHP: Retrieving data

I'm stuck in retrieving some sort of data in my view. I have to list information of a certain "Job", which has different attributes already stored in the database.
For example, I'd like to get the field of 'weighting' listed.
The debug($this->viewVars) prints me this (which represents what's stored in the DB):
'JobValues' => array(
(int) 0 => array(
'id' => '1',
'yearly_job_id' => '1',
'institution_type_id' => '1',
'norm_rate' => '5',
'weighting' => '5.00',
'standard_value' => '5.00',
'education_weeks' => '5.0',
'group_distribution' => '0.50',
'YearlyJob' => array(
'id' => '1',
'year_id' => '1',
'job_id' => '1',
'full_time_jobs_needed' => true,
'education_count_needed' => true,
'is_care' => true
),
Normally I would just print this: echo([JobValue][weighting]);, but there is a number in between, so echo([JobValue][1][weighting]); won't lead to success. What could I implement in my view (or model)? Any advice is highly appreciated.
For printing out the data, if there's only one top level of array, just remove it. print_r(array_shift($foo['JobValues']['weighting']));
If there are multiple arrays on the same level, you need to do a foreach to iterate into each one of the record.

Categories