Everyone who calls over Weibo http://open.weibo.com/wiki/ 2/statuses/upload this interface is a microblogging released with pictures;
Which has a picture of the parameters are binary type, I think it should be in Java byte [] it, in accordance with its requirements, should I use a POST request and these parameters plus;
The problem is, POST how to add byte [] parameter ah? ?
I was OAuth2.0 manner authorized use.
Online, ah, hastily.
Reply:
Add me Q 87452213, I tell you
Reply:
Thank you upstairs.
I want to see if they have no better way easier
Reply:
The image into a binary array on the line. http://topic.csdn.net/u/20120529/09/156e88dd-d1da-4739-8a27-c9f7d40a0588.html
Refer to this article, I have to reply before too
-------------------------------------------------- -------------------------
Of particular note is that our sdk is weibo4j-oauth2.jar
Another explanation is that the picture is a binary pass past
LZ should look at the official demo
Weibo weibo = new Weibo ();
weibo.setToken ("sina token");
Timeline tm = new Timeline ();
Status status = null;
String content = "xxxx";
byte [] img = null ;/ / Here is a picture of binary data
if (img! = null && img.length> 0) {
ImageItem ii = new ImageItem (img);
status = tm.UploadStatus (URLEncoder.encode (content, "UTF-8"), ii);
} Else {
status = tm.UpdateStatus (content);
}
Reply:
Read, you say these are the old version of it?
I use is a new version, like what the Timeline, ImageItem the like are not
private String upload (Weibo weibo, String source, String file, String status, String lon,
String lat) throws WeiboException {
WeiboParameters bundle = new WeiboParameters ();
bundle.add ("source", source);
bundle.add ("pic", file);
bundle.add ("status", status);
if (! TextUtils.isEmpty (lon)) {
bundle.add ("lon", lon);
}
if (! TextUtils.isEmpty (lat)) {
bundle.add ("lat", lat);
}
String rlt = "";
String url = Weibo.SERVER + "statuses / upload.json";
try {
rlt = weibo
. Request (this, url, bundle, Utility.HTTPMETHOD_POST, mWeibo.getAccessToken ());
} Catch (WeiboException e) {
throw new WeiboException (e);
}
return rlt;
}
This is the official gave an example, I do not know how they write, but do not know how to pass parameters inside the picture, how is a String type.
I saw it on fire, there are mixed feelings about this: Sina thing I've ever seen, used the worst, a little bit of professionalism are not
Reply:
Dude, you are not kind ah.
It comes with the Utility class hapless official had all the code you gave me, but exactly

Reply:
Solved yet, and I ask ah
No comments:
Post a Comment