gpt4 book ai didi

java - 从 Linkedin 得到空白回复

转载 作者:可可西里 更新时间:2023-11-01 16:36:23 24 4
gpt4 key购买 nike

我试图在 Codename 一个应用程序中成功登录后请求用户信息,但是当登录用户重定向到该应用程序时,却没有得到任何响应。

以下是我的代码:

linked.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {


Oauth2 auth2 = new Oauth2("https://www.linkedin.com/oauth/v2/authorization",
"XXXXXXXXXX",
"https://www.codenameone.com","",
"https://www.linkedin.com/oauth/v2/accessToken",
"XXXXXXXXXX");

//auth2.authenticate();
auth2.showAuthentication(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
AccessToken token = (AccessToken) evt.getSource();
JSONObject object = new JSONObject(token);
try {
TOKEN = object.getString("token");
Log.p(TOKEN);


ConnectionRequest linkedinreq = new ConnectionRequest(){
@Override
protected void readResponse(InputStream input) throws IOException {
Log.p(input.toString());
}

};
linkedinreq.setPost(false);
linkedinreq.setUrl("https://api.linkedin.com/v1/people/~:(id,num-connections,picture-url)");
linkedinreq.addArgumentNoEncoding("oauth2_access_token", TOKEN);
linkedinreq.addArgumentNoEncoding("format", "json");
NetworkManager.getInstance().addToQueue(linkedinreq);


} catch (JSONException ex) {
ex.printStackTrace();
}
}
});
Oauth2.setBackToParent(true);


}
});

以及显示空响应的网络监视器快照

enter image description here

并在控制台输出显示

[Network Thread] 0:0:1,12 - com.codename1.impl.javase.JavaSEPort$67@41ca2b3e

最佳答案

覆盖此消息后,您可以收到任何错误消息并调用 setreadResponseErrors(true);这将显示错误消息和响应代码。

linkedinreq.setReadResponseForErrors(true);
@Override
protected void handleErrorResponseCode(int code, String message) {
System.out.println("code: " + code + "message: " + message);
}

关于java - 从 Linkedin 得到空白回复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43116921/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com