Here is a request code :
public User getUserInfo (User user) {
StringBuilder buffer = null;
/ / String url = "https://api.weibo.com/2/users/show.json" ;/ / new
String url = "http://api.t.sina.com.cn/users/show.json" ;/ / legacy
List
params.add (new BasicNameValuePair ("source", oAuth.APP_KEY));
params.add (new BasicNameValuePair ("user_id", user.getUser_id ()));
HttpResponse response = oAuth.signRequest (user.getToken (), user.getToken_secret (), url, params);
Log.i ("tools", "------- getUserInfo - request to return the verification code ------" + (int) response.getStatusLine (). getStatusCode ());
....
}
above "------- getUserInfo - request to return the verification code ------ " Log return result: 403
cause other operations can not be executed !
This code runs in yesterday requested the return is 200 today, a run on the wrong, to return into a 403
seeking predecessors analysis
function parameters user is to use id = null, user_id = 2598494867, user_name = null, token = 89c2d7fead33a666bbfe694327651b9b, token_secret = e6e1916f037d9de838d7df959d101616, description = null, user_head = null processing out
oAuth call signRequest as follows:
public HttpResponse signRequest (String token, String tokenSecret,
String url, List params) {
HttpPost post = new HttpPost (url);
ByteArrayOutputStream bos = null;
String file = null;
try {
post.setEntity (new UrlEncodedFormEntity (params, HTTP.UTF_8));
for (int i = 0; i
. get (i);
if (nameValuePair.getName (). equals ("pic" ;) ) {
file = nameValuePair . getValue ();
}
}
byte [] data = null;
bos = new ByteArrayOutputStream (1024 * 50);
if (! TextUtils.isEmpty (file)) {
paramToUpload (bos, params);
post.setHeader ("Content-Type", MULTIPART_FORM_DATA + "; boundary =" + BOUNDARY);
Bitmap bf = BitmapFactory.decodeFile (file);
imageContentToUpload (bos, bf);
data = bos.toByteArray ();
ByteArrayEntity formEntity = new ByteArrayEntity (data);
post.setEntity (formEntity);
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace ();
} finally {
if (bos! = null) {
try {
bos.close ();
} catch (IOException e) {
e.printStackTrace ();
}
}
}
post.getParams (). setBooleanParameter (
CoreProtocolPNames.USE_EXPECT_CONTINUE, false);
return signRequest (token, tokenSecret, post);
}
------ Solution ------------------------------------ --------
maybe after a while , wait a few hours and try it.
people Sina is not available to casual users test play . Maybe the server refused, they too will be fine.
------ Solution ---------------------------------------- ----
403 representatives Forbidden
I'm afraid you check under your test account is not being Band , right ?
------ For reference only -------------------------------------- -
there such a thing ?
------ For reference only -------------------------------------- -
Sina microblogging server is not the problem ah ?
------ For reference only -------------------------------------- -
has been resolved, Sina Weibo close all unapproved legacy interfaces , the July 24 start
------ For reference only ------------ ---------------------------
two days I have encountered this problem , HttpResponse return 403 , in the end the question is Sina , or procedural problem ? Solution. . .
------ For reference only -------------------------------------- -
also encountered the same problem, how to solve ah
------ For reference only ----------------------- ----------------
Well , I'll end stickers, now online most of the code are used in the old version of the excuse. The old version of the interface has been Sina ban ! So online to see some examples have not achieved .
or on their own study new interface implementation , or see the new tutorial !
------ For reference only -------------------------------------- -
rely on ! Finally he found the symptoms of ! ! ! !
没有评论:
发表评论