Summary of SMS verification code using Ali Big Fish
do is the app directly call Ali Big fish SMS Verification code and then the local storage of the random six-digit comparison, the following steps:
1. First of all, enter the open platform of Ali Big Fish first http://open.taobao.com/doc2/apiDetail?spm=0.0.0.0.D1PYJd&apiId=25450
2. Then you can see some of the parameters (common parameters and request parameters) that the document center lets us pass. Here I list some of the parameters I passed myself
The first thing we see is the first parameter
Appkey, this one's registered.
Format is a fixed-pass JSON
method is also a fixed transmission Alibaba.aliqin.fc.sms.num.send
Rec_num is the cell phone number you receive.
Sign, this is the last word, and that's after the signature.
Sign_method the way you signed it, I'm using MD5.
Sms_free_sign_name This parameter is the template name you requested on the platform
Sms_param This is your platform Application template format where name is a variable parameter placeholder
Sms_template_code This is the template ID for the platform application.
The Sms_type is a fixed-pass normal.
There are also 2 parameters
One is timestamp and the other is v.
V is fixed pass 2.0
Timestamp is to pass the current time according to the time format of Ali Big Fish
The parameters and parameter values on my side have been utf-8 URL encoding
Here I list coding methods This method has been looking for a long time
+ (nsstring *) urlformstring: (nsstring *) string{
nsstring * encodedstring = (nsstring *)cfbridgingrelease( Cfurlcreatestringbyaddingpercentescapes(
kcfallocatordefault,
(cfstringref) string,
NULL,
(cfstringref)@ ":/?#[]@!$ & ' () *+,;=<>%{}|^~ '",
cfstringconvertnsstringencodingtoencoding(nsutf8stringencoding));
return encodedstring;
}
I've been transcoding some special characters in this, or I'm not going to be able to recognize the background, for example:
Now that's the code, let's talk about how it's going to be a pit. The way I use the network request is afnetworking because the time format required by the big fish is passed in a fixed format yyyy-mm-dd HH:mm:ss
You can see that there are spaces in the middle of this time format.
The space is encoded on the iOS side and becomes%20, but the space format that Java or PHP receives in the background is + so I'm here to use the + instead of%20.
nsstring *hexstr=[hextransformstring urlformstring:d atetime];
nsstring *replacstr=[hexstr stringbyreplacingoccurrencesofstring:@ "%20" Withstring:@ "+"];
At this point I started using the AF post to pass the dictionary type.
But I didn't see it at the time. The parameter and parameter values have been coded again at the AF bottom. + Becomes%2b
So here I have no dictionary type passed the direct use of the form of the URL stitching (time is not too much to think of)
All right, here's the signature signature, I'm using JAVASDK.
Next steps:
1. Manually Follow ASCII Ordering is the first one before the first letter and then the second one.
2. MD5 encryption of strings with all parameters and parameter values stitched together
3. Then convert all uppercase letters to lowercase
A summary is one step:
NSString *md5str=[[str md5string] uppercasestring];
STR is a string that is manually sorted by ASCII code
I'm going to write about it here today. If there's anything inaccurate, I hope you twos.
The use of Ali big Fish