import java.io.*;
import okhttp3.*;
public class main {
public static void main(String []args) throws IOException{
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n \"owner_setting\": {\r\n \"contact_email\": \"lightsnowliu@qq.com\",\r\n \"notice_method\": \"notice_method\"\r\n },\r\n \"setting_list\": [\r\n {\r\n \"privacy_key\": \"UserInfo\",\r\n \"privacy_text\": \"用户信息(微信昵称、头像)\"\r\n },\r\n {\r\n \"privacy_key\": \"Location\",\r\n \"privacy_text\": \"位置信息\"\r\n },\r\n {\r\n \"privacy_key\": \"Invoice\",\r\n \"privacy_text\": \"发票信息\"\r\n },\r\n {\r\n \"privacy_key\": \"Album\",\r\n \"privacy_text\": \"选中的照片或视频信息\"\r\n },\r\n {\r\n \"privacy_key\": \"PhoneNumber\",\r\n \"privacy_text\": \"手机号码\"\r\n },\r\n {\r\n \"privacy_key\": \"AlbumWriteOnly\",\r\n \"privacy_text\": \"相册(仅写入)权限\"\r\n }\r\n ],\r\n \"privacy_ver\": 2\r\n}");
Request request = new Request.Builder()
.url("https://api.weixin.qq.com/cgi-bin/component/setprivacysetting?access_token=51_c4Gqg1CHCsCufBexYwQhwUgmfi5jIZkBVn4vIqyRdEM7qR6_Khf3gdp2tXuONdTm09b2-wexNA4T43Bbv9_sPYcKXlA7WQt6vzjeJQ6XoeTp_kTg7kngHlOgo71fIKj6kQg4A4z9E6STkEbADKLaAEDZGH")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
System.out.println(response.body().string());
}
}
小程序APPID: wx96b6fafe7617024e
我用上述方法提交用户隐私设置的setting_list,返回的结果为 {"errcode":0,"errmsg":"ok"} 相应成功,但是我再次调用get方法查询权限列表时发现时间没有更新,说明我之前的设置并没有生效,麻烦大神 帮忙看一下为啥。
不用okhttp就会生效?