All Downloads are FREE. Search and download functionalities are using the official Maven repository.

weixin.popular.api.TicketAPI Maven / Gradle / Ivy

Go to download

The weixin-popular is a JAVA SDK for weixin. Weixin web url is https://mp.weixin.qq.com.

There is a newer version: 2.8.43
Show newest version
package weixin.popular.api;

import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.client.methods.RequestBuilder;
import weixin.popular.bean.ticket.Ticket;
import weixin.popular.client.LocalHttpClient;

/**
 * JSAPI ticket
 * @author LiYi
 *
 */
public class TicketAPI extends BaseAPI{
	
	/**
	 * 获取 jsapi_ticket
	 * @param access_token access_token
	 * @return ticket
	 */
	public static Ticket ticketGetticket(String access_token){
		return ticketGetticket(access_token,"jsapi");
	}

	/**
	 * 获取 ticket
	 * @param access_token access_token
	 * @param type jsapi or wx_card
	 * @return ticket
	 */
	public static Ticket ticketGetticket(String access_token,String type){
		HttpUriRequest httpUriRequest = RequestBuilder.get()
				.setUri(BASE_URI + "/cgi-bin/ticket/getticket")
				.addParameter(PARAM_ACCESS_TOKEN, API.accessToken(access_token))
				.addParameter("type", type)
				.build();
		return LocalHttpClient.executeJsonResult(httpUriRequest,Ticket.class);
	}
	public static Ticket getTicketFromProxy(String url){
		HttpUriRequest httpUriRequest = RequestBuilder.get()
				.setUri(url)
				.build();
		return LocalHttpClient.executeJsonResult(httpUriRequest,Ticket.class);
	}

	public static void main(String[] args) {
		Ticket ticket = TicketAPI.getTicketFromProxy("http://localhost:3000/ticket");
		System.out.println(ticket);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy