【发布时间】:2015-11-29 11:08:40
【问题描述】:
我正在开发一款 Instagram 集成应用。我想取消关注一个用户,但我从 Instagram 得到了不相关的答案,包括 html doctype 说“抱歉,此页面不可用”。我在我的访问令牌 url 中提到了关系权限。是否需要审核流程?这是我的代码:
new Thread(new Runnable() {
@Override
public void run() {
try{
String urlFollowUnFollow = "https://api.instagram.com/v1/users/"
+ username
+ "/relationship?access_token="
+ GetStats.ACCESS_TOKEN;
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
nameValuePairs.add(new BasicNameValuePair("action", "unfollow"));
try {
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(urlFollowUnFollow);
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(
is, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
response = sb.toString();
} catch (Exception e) {
Log.e("Buffer Error", "Error converting result " + e.toString());
}
System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!" + response + " !!!!!!!!!!!!!!!!!!!!!!!!!");
} catch (Exception exception) {
exception.printStackTrace();
}
}}
).start();
顺便说一句,我看过其他 stackoverflow 帖子。没有帮助。提前致谢。
【问题讨论】: