Redis Session Storage Issue - redis

I am a newbie in using Redis as my Cache storage.I am using it to store Cakephp Session in it.But when I store the session in it, It stores them as serialized Json. Now my question is How to store unserialized json in Redis using Cakephp ?
In programming i am able to use the session correctly but when i tried to get the data from cli it gives me something like shown in the update question. I think it is not pure serialized json as when i tried to unserialized it gives me error.
"s:3141:\"Config|a:1:{s:4:\"time\";i:1533905976;}session_start_time|s:19:\"2018-08-10 18:29:34\";Auth|a:1:{s:4:\"User\";a:19:{s:11:\"merchant_id\";i:16;s:4:\"name\";s:8:\"google\";s:5:\"email\";s:18:\"google#gmail.com\";s:8:\"username\";s:8:\"google\";s:7:\"balance\";s:11:\"92629148.57\";s:22:\"balance_deduction_type\";s:4:\"LIVE\";s:16:\"validate_txn_url\";s:67:\"http://";s:24:\"payment_verification_url\";s:49:\"http://";s:28:\"transaction_notification_url\";s:60:\"http://";s:11:\"sendsms_url\";s:45:\"http://";s:14:\"other_payments\";s:57:\"http://";s:9:\"client_ip\";s:0:\"\";s:7:\"created\";O:20:\"Cake\I18n\FrozenTime\":3:{s:4:\"date\";s:26:\"2017-08-04 04:41:55.000000\";s:13:\"timezone_type\";i:3;s:8:\"timezone\";s:13:\"Asia/Calcutta\";}s:8:\"modified\";N;s:6:\"status\";s:6:\"ACTIVE\";s:4:\"type\";N;s:8:\"tds_rate\";d:0;s:12:\"api_key_hash\";s:32:\"b92c131e5bed70d3b596b1d0f3d7631b\";s:12:\"merchant_ips\";s:66:\"192.168.134.42,127.0.0.1,172.20.2.37,115.249.4.214,192.168.131.253\";}}MR|a:28:{s:11:\"merchant_id\";i:16;s:13:\"merchant_name\";s:8:\"google\";s:17:\"merchant_users_id\";s:6:\"5Adi01\";s:19:\"merchant_user_state\";s:5:\"DELHI\";s:24:\"merchant_user_branchcode\";s:3:\"B01\";s:16:\"merchant_channel\";s:6:\"RETAIL\";s:8:\"services\";s:14:\"GENERAL~HEALTH\";s:6:\"device\";s:7:\"WINDOWS\";s:20:\"merchant_lasttransno\";s:11:\"14507001061\";s:22:\"balance_deduction_type\";s:4:\"LIVE\";s:13:\"merchant_type\";N;s:24:\"payment_verification_url\";s:49:\"http:";s:7:\"sms_url\";s:45:\"http://";s:28:\"transaction_notification_url\";s:60:\"http:";s:16:\"validate_txn_url\";s:67:\"http://";s:14:\"other_payments\";s:57:\"http://";s:8:\"tds_rate\";d:0;s:10:\"retPanName\";s:13:\"PRITESH KUMAR\";s:5:\"rname\";s:19:\"Demo id 1 of Aditya\";s:8:\"rphoneno\";s:10:\"9654382580\";s:10:\"retEmailId\";s:27:\"satyendra.jain#skilrock.com\";s:10:\"retAddress\";s:74:\"K-230,VILLAGE KARAWAL NAGAR, Karawal Nagar, EAST DELHIDELHI, India, 110094\";s:14:\"retAddresscity\";s:10:\"EAST DELHI\";s:10:\"retStateId\";s:1:\"5\";s:16:\"diskSerialNumber\";s:22:\"pwdt-web-1332130123428\";s:11:\"merchantids\";s:13:\"5Adi01,5Adi01\";s:10:\"req_params\";a:21:{s:8:\"username\";s:8:\"google\";s:8:\"password\";s:8:\"12345678\";s:12:\"retailercode\";s:6:\"5Adi01\";s:5:\"state\";s:5:\"DELHI\";s:7:\"transno\";s:11:\"14507001061\";s:8:\"checksum\";s:9:\"962335274\";s:7:\"channel\";s:6:\"retail\";s:5:\"rname\";s:19:\"Demo id 1 of Aditya\";s:7:\"phoneno\";s:10:\"9654382580\";s:6:\"device\";s:7:\"WINDOWS\";s:7:\"service\";s:14:\"GENERAL~HEALTH\";s:7:\"product\";s:0:\"\";s:11:\"merchantids\";s:13:\"5Adi01,5Adi01\";s:12:\"diskserialno\";s:22:\"pwdt-web-1332130123428\";s:5:\"brand\";s:2:\"PW\";s:8:\"google\";s:9:\"insurance\";s:11:\"countercode\";s:6:\"5Adi01\";s:9:\"machineid\";s:9:\"BECZPULLS\";s:12:\"pw_sessionid\";s:0:\"\";s:7:\"apptype\";s:4:\"RPOS\";s:6:\"appver\";s:4:\"3.25\";}s:8:\"products\";s:0:\"\";}\";"

Related

How do we filter the entities which is not start with "msdn" using MSDynamics Web API

I want to get all entities which are the name not start the prefix as 'msdn' from ms dynamics.
I tried the below APIs, got the error.
GET /api/data/v9.1/EntityDefinitions?$select=LogicalName&$filter=not startswith(LogicalName,%27msdn%27)
Response :
{
"error":
{"code":"0x0",
"message":"The \"startswith\" function isn't supported for Metadata Entities."
}
}
I referred https://learn.microsoft.com/en-us/powerapps/developer/common-data-service/webapi/query-data-web-api#standard-query-functions
I have checked that in one of my environment as well. What you require is not possible.
You will have to go 2 steps.
Retrieve all entities and then filter them out in your local program may it be JavaScript/C# or Json filtering/Power automate or something.

Update secret parameter in Jenkins Job

I have a lot of free-style jobs in my Jenkins instance. I create them with Jenkins API (generate XML-file with configuration and post them by "http://my-jenkins-instance:8080/createItem?name=JobName").
There is one problem - I can not generate value in secret fields. For example, I want such a config:
Inject passwords to the build as environment variables -> Job passwords.
And I need to set 123 to Password field.
I can not do this through XML because it appears decoded in XML. Something like this: {AQAAABAAAANwHq0hsSF6...}
I want to set the value to this parameter
So my questions are:
Can I get the decoded value of a plain password through some API? So I could send 123 and get {AQAAABAAAANwHq0hsSF6...} back.
If not, can I set secret value some other way? I can only think of using Selenium but it is too slow (comparing to API).
I have found the solution.
I can set the value as a plain text: <value>123</value>, create or update a job. Then I need to disable and enable the job.

How to call multiple quotes from IEX Cloud API

I am trying to use IEX Cloud to get stock quotes for multiple stocks with one API call.
Here is my api call for Apple,Facebook, and Tesla. What am I doing wrong?
https://cloud.iexapis.com/stable/stock/market/batch?symbols=aapl,fb,tsla&types=quote?token=MY_TOKEN_HERE
The Error Message returned from the API is this:
"types" required with a valid value
I think the main problem was question mark between 'quote' and token. It should be '&' instead. I replicated your error with question mark, but with & it works just fine.
Here is what works for me: https://cloud.iexapis.com/v1/stock/market/batch?&types=quote&symbols=aapl,fb,tsla&token=YOUR_TOKEN_HERE
if you want to retrieve just the latest price, you can use following call:
https://cloud.iexapis.com/v1/stock/market/batch?&types=price&symbols=aapl,fb,tsla&token=YOUR_TOKEN_HERE
You can learn more at this link: How do I query multiple symbols or data types in one API Call? (for production you use cloud.iexapis.com instead of sandbox)
as of 2nd-July-2022,
This is how I structured my URL for a batch request.
const tickerArray = ["AAPL", "META", "GOOGL", "TSLA"];
`https://cloud.iexapis.com/v1/stock/market/batch?symbols=${tickerArray.toString().toLowerCase()}&types=quote&token=${process.env.IEXCLOUD_API_KEY}`

Insert chinese using odata client to azure sql

I am using azure aql as a backend for a windows phone app I am writing. I expose the db using odata protocol, and using the odata client library to read and write db. I am having a problem to insert Chinese strings. Each chinese charatcter will show up as "?" in the db.
The following is the code. Using the debugger, i can tell, the chinese character is still in the write format before the BeginSaveChanges call. The according field in the db is defined as nvarchar. I can put chinese no problem from the web management portal.
NewJoke.Title = Regex.Replace(NewJoke.Title, "'", "''");
NewJoke.Content = Regex.Replace(NewJoke.Content, "'", "''");
dsc = new DataServiceContext(funnyJokesUri);
try
{
//Name of the entity goes into the first attribute of the AddObject method followed by the entity itself
//INSERTING
dsc.AddObject("Jokes", NewJoke);
dsc.BeginSaveChanges(insertJoke_Completed, dsc);
}
You have to set the collation for Chinese on the column, I think. More... http://blogs.msdn.com/b/sqlazure/archive/2010/06/11/10023650.aspx
BTW -- I wasn't clear on reading your question -- it sounds like you're saying the db stores the chinese fine when you use the web portal to insert it; but presumably, it does not store the chinese when you use some other method for inserting it. (?) Is that what you're saying?

Can Flash be integrated with SQL?

Can Flash be used together with SQL? I have a Flash form and I need to connect it to SQL. If there is any example on the net about this topic. I can't find it.
You don't use ActionScript directly with an SQL database. Instead you make http requests from ActionScript to a server, specifying the correct parameters. A typical opensource setup, is a PHP script communicating with a MySQL DB, but you can use Java with Oracle, Ruby with CouchDB, .NET with SQL or any other possible configuration. The important point is that you must be able to call a server script and pass variables... typically a Restful setup.
Once your PHP script has been properly configured, you can use http POST or http GET to send values from ActionScript.
PHP:
<?php
$updateValue = $_POST["updateValue"];
$dbResult = updateDB( $updateValue ); //This should return the db response
echo( $dbResult );
?>
To call this script from ActionScript, you need to create a variables object.
var variables:URLVariables = new URLVariables();
variables.updateValue = "someResult";
The variable name .updateValue, must match the php variable exactly.
now create a URLRequest Object, specifying the location of your script. For this example the method must be set to POST. You add the variable above to the data setter of the request.
var request:URLRequest = new URLRequest( "yourScript.php" );
request.method = URLRequestMethod.POST;
request.data = variables;
Now create a URLLoader and add an event listener. Do not pass the request created above to the constructor, but to the load method.
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, onComplete );
loader.load( request );
The handler would look something like this.
private function onComplete( e:Event ) : void
{
trace( URLLoader( e.target ).data.toString() );
}
This example shows how to update and receive a response from a server / db combo. However, you can also query a DB through the script and parse the result. So in the PHP example above, you can output JSON, XML or even a piped string, and this can be consumed by ActionScript.
XML is a popular choice, as ActionScript's e4x support treats XML like a native object.
To treat the response above like an XML response, use the following in the onComplete handler.
private function onComplete( e:Event ) : void
{
var result:XML = XML( URLLoader( e.target ).data );
}
This will throw an error if your xml is poorly formed, so ensure the server script always prints out valid XML, even if there is a DB error.
The problem with this is giving someone a flash file that directly accesses SQL server is very insecure. Even if it's possible, which I have seen SOCKET classes out there to do so for MySQL (though never used it), allowing users to remotely connect to your DB is insecure as the user can sniff the login information.
In my opinion, the best way to do this is to create a Client/Server script. You can easily do this with PHP or ASP.net by using SendAndLoad to send the data you need to pass to SQL via POST fields. You can then send back the values in PHP with:
echo 'success='.+urlencode(data);
With this, flash can access the data via the success field.
I don't personally code flash but I work with a company who develops KIOSK applications for dozens of tradeshow companies, and my job is to store the data, return it to them. This is the method we use. You can make it even cleaner by using actual web services such as SOAP, but this method gets the job done if its just you using it.
You should look into Zend Amf or even the Zend Framework for server side communication with Flash. As far as I know Zend Amf is the fastest way to communicate with PHP ( therefore your database ) also you can pass & return complex Objects from the client to the server and vice versa.
Consider this , for instance. You have a bunch of data in your database , you implement functions in ZF whereas this data is formatted and set as a group of Value Objects. From Flash , you query ZF , Zf queries the database , retrieve & formats your data, return your Value Objects as a JSON string ( for instance ). In Flash, you retrieve you JSON string , decode it and assign your Value Objects to whatever relevant classes you have.
There are plenty of tutorials out there regarding Flash communication with the Zend Framework.
Here's an example:
http://gotoandlearn.com/play.php?id=90