Details about logon instances for applet development

Source: Internet
Author: User
The technology level is generally limited. what's wrong? Let us know. The popularity of small programs is almost the same, recording the ups and downs in your development. Follow the official process to log on: Logon process

The technology level is generally limited. what's wrong? Let us know.

The popularity of small programs is almost the same, recording the ups and downs in your development.

Follow the official process to log on:

First, create a request method to implement a communication between your server and the server:

Public static String GET (String url) {String result = ""; BufferedReader in = null; try {URL realUrl = new URL (url); URLConnection conn = realUrl. openConnection (); conn. connect (); Map
 
  
> Map = conn. getHeaderFields (); in = new BufferedReader (new InputStreamReader (conn. getInputStream (); String line; while (line = in. readLine ())! = Null) {result + = line ;}} catch (Exception e) {} finally {try {if (in! = Null) {in. close () ;}} catch (Exception e2) {// log records} return result ;}
 

Then construct the request url (change the property changed from the red circle to the corresponding data ):

Use the GET () method to communicate with the server. if the request is correct, we can GET session_key and openid, and store these two values in the session:

Jedis jedis = new Jedis("localhost");             String openid = openid;String session_key = session_key;String uid = UUID.randomUUID().toString();StringBuffer sb = new StringBuffer();sb.append(openid);sb.append(","+session_key);jedis.set(uid, sb.toString());

Return the uid to the client. in the future, each request from the client will contain the uid.

Troubleshooting

If you need to obtain the user name and profile picture of the logged-on user during the process, garbled characters will appear if the user name has Chinese characters. the solution is as follows:

String nickNameDecode = new String(nickName.getBytes("ISO-8859-1"),"utf-8");

The above is a detailed description of the logon instance for applet development. For more information, see other related articles in the first PHP community!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.