java代码发送微博 微博转发代码
微博无限转发代码
在Java书本中。微博是现在一款比较火的软件,微博的无限转发代码是Java中的一个代码,在Java的书本中就可以找到无限转发的代码,主需要依照书本写出来就可以进行。
成都创新互联主要从事网站建设、成都网站设计、网页设计、企业做网站、公司建网站等业务。立足成都服务英吉沙,十载网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:028-86922220
求真正有效的可以模拟登录新浪微博的java代码,后续可以用Jsoup进行抓取。急急!!登录成功马上给分!
package jsoupTest;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.jsoup.Connection.Method;
import org.jsoup.Connection.Response;
import org.jsoup.Jsoup;
public class JsoupTest {
public static void main(String[] args) throws IOException {
MapString, String map = new HashMap();
//map.put请根据自己的微博cookie得到
Response res = Jsoup.connect("别人的主页id")
.cookies(map).method(Method.GET).execute();
String s = res.body();
System.out.println(s);
String[] ss = s.split("scriptFM.view");
int i = 0;
// pl_content_homeFeed
// pl.content.homeFeed.index
ListString list = new ArrayList();
for (String x : ss) {
// System.out.println(i++ + "======================================");
// System.out.println(x.substring(0,
// x.length() 200 ? 200 : x.length()));
// System.out.println("===========================================");
if (x.contains("\"html\":\"")) {
String value = getHtml(x);
list.add(value);
System.out.println(value);
}
}
// content=ss[8].split("\"html\":\"")[1].replaceAll("(\\\\t|\\\\n)",
// "").replaceAll("\\\\\"", "\"").replaceAll("\\\\/", "/");
// content=content.substring(0,
// content.length()=13?content.length():content.length()-13);
// System.out.println(Native2AsciiUtils.ascii2Native(content));
}
public static String getHtml(String s) {
String content = s.split("\"html\":\"")[1]
.replaceAll("(\\\\t|\\\\n)", "").replaceAll("\\\\\"", "\"")
.replaceAll("\\\\/", "/");
content = content.substring(0,
content.length() = 13 ? content.length()
: content.length() - 13);
return Native2AsciiUtils.ascii2Native(content);
}
如何在java中实现sql递归查询,实现微博转发路径的表示,如以下表
create table message(
InfoID int,
TransID int,
UserName varchar(20)
);
insert into message(InfoID,TransID,UserName) values(1000,2000,'张三');
insert into message(InfoID,TransID,UserName) values(2000,3000,'李四');
insert into message(InfoID,TransID,UserName) values(3000,4000,'王五');
insert into message(InfoID,UserName) values(4000,'小刘');
首先找到第一个发微博的人,怎么确定呢?因为他的TransID也就是转发消息ID 为NULL
select UserName from message where TransID is null
+----------+
| UserName |
+----------+
| 小刘 |
+----------+
取出第一个转发微博的姓名
select UserName from message where TransID in(
select InfoID from message where TransID is null)
+----------+
| UserName |
+----------+
| 王五 |
+----------+
取出第二个转发微博的姓名
select UserName from message where TransID in(
select InfoID from message where TransID in(
select InfoID from message where TransID is null)
)
+----------+
| UserName |
+----------+
| 李四 |
+----------+
取出第三个转发微博的姓名
select UserName from message where TransID in(
select InfoID from message where TransID in(
select InfoID from message where TransID in(
select InfoID from message where TransID is null)
)
)
+----------+
| UserName |
+----------+
| 张三 |
+----------+
然后把所有人连起来
select UserName from message where TransID is null
union
select UserName from message where TransID in(
select InfoID from message where TransID is null)
union
select UserName from message where TransID in(
select InfoID from message where TransID in(
select InfoID from message where TransID is null)
)
union
select UserName from message where TransID in(
select InfoID from message where TransID in(
select InfoID from message where TransID in(
select InfoID from message where TransID is null)
)
)
运行的结果:
+----------+
| UserName |
+----------+
| 小刘 |
| 王五 |
| 李四 |
| 张三 |
+----------+
以上代码就是给你一个思路, 最好写一个循环来查找,按照这个思路做
希望对你有帮助
java web怎样实现分享到微信
代码很简单,我这里就不多废话了,直接奉上源码:
复制代码 代码如下:
%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%
%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%
!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
html
head
base href="%=basePath%"
title喝喝/title
meta http-equiv="pragma" content="no-cache"
meta http-equiv="cache-control" content="no-cache"
meta http-equiv="expires" content="0"
meta http-equiv="keywords" content="keyword1,keyword2,keyword3"
meta http-equiv="description" content="This is my page"
!--
link rel="stylesheet" type="text/css" href="styles.css"
--
script
var imgUrl = '
var lineLink = '
var descContent = "万达狂欢节, 夺宝幸运星大抽奖活动开始啦!";
var shareTitle = '万达狂欢节';
var appid = 'wxc9937e3a66af6dc8';
function shareFriend() {
WeixinJSBridge.invoke('sendAppMessage',{
"appid": appid,
"img_url": imgUrl,
"img_width": "640",
"img_height": "640",
"link": lineLink,
"desc": descContent,
"title": shareTitle
}, function(res) {
_report('send_msg', res.err_msg);
})
}
function shareTimeline() {
WeixinJSBridge.invoke('shareTimeline',{
"img_url": imgUrl,
"img_width": "640",
"img_height": "640",
"link": lineLink,
"desc": descContent,
"title": shareTitle
}, function(res) {
_report('timeline', res.err_msg);
});
}
function shareWeibo() {
WeixinJSBridge.invoke('shareWeibo',{
"content": descContent,
"url": lineLink,
}, function(res) {
_report('weibo', res.err_msg);
});
}
// 当微信内置浏览器完成内部初始化后会触发WeixinJSBridgeReady事件。
document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
// 发送给好友
WeixinJSBridge.on('menu:share:appmessage', function(argv){
shareFriend();
});
// 分享到朋友圈
WeixinJSBridge.on('menu:share:timeline', function(argv){
shareTimeline();
});
// 分享到微博
WeixinJSBridge.on('menu:share:weibo', function(argv){
shareWeibo();
});
}, false);
/script
/head
body
!-- script
var imgUrl = "
var lineLink = "
var descContent = '测试别当真';
var shareTitle = '分享';
var appid = 'wx1259b351c201841d';
function shareFriend() {
WeixinJSBridge.invoke('sendAppMessage',{
"appid": appid,
"img_url": imgUrl,
"img_width": "200",
"img_height": "200",
"link": lineLink,
"desc": descContent,
"title": shareTitle
}, function(res) {
//_report('send_msg', res.err_msg);
});
}
function shareTimeline() {
WeixinJSBridge.invoke('shareTimeline',{
"img_url": imgUrl,
"img_width": "200",
"img_height": "200",
"link": lineLink,
"desc": descContent,
"title": shareTitle
}, function(res) {
//_report('timeline', res.err_msg);
});
}
function shareWeibo() {
WeixinJSBridge.invoke('shareWeibo',{
"content": descContent,
"url": lineLink,
}, function(res) {
//_report('weibo', res.err_msg);
});
}
// 当微信内置浏览器完成内部初始化后会触发WeixinJSBridgeReady事件。
document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
// 发送给好友
WeixinJSBridge.on('menu:share:appmessage', function(argv){
shareFriend();
});
// 分享到朋友圈
WeixinJSBridge.on('menu:share:timeline', function(argv){
shareTimeline();
});
// 分享到微博
WeixinJSBridge.on('menu:share:weibo', function(argv){
shareWeibo();
});
}, false);
/script --
h1呵呵呵呵/h1
/body
/html
调用新浪微博内容接口要怎么用……JAVA有关
实现调用微博内容的Java程序如下:(注意注释)为保护隐私运行结果就不贴出来了。
import java.io.BufferedWriter;import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.Iterator;
import java.util.List;
import weibo4j.Timeline;
import weibo4j.model.Status;
import weibo4j.model.StatusWapper;
import weibo4j.model.WeiboException;
public class F { public static void main(String[] args) {
String userID="";//这里由于保护隐私请自己填写userID
String token="";//这里由于保护隐私请自己填写token
Timeline t=new Timeline();
t.client.setToken(token);
StatusWapper sw=null;
ListStatus status=null;
BufferedWriter bw=null;
try{
sw=t.getUserTimelineByUid(userID);
status=sw.getStatuses();
bw=new BufferedWriter(new OutputStreamWriter(new FileOutputStream("D:\\status.txt"),"gbk"));
IteratorStatus iterator=status.iterator();
Status s=null;
while(iterator.hasNext()){
s=(Status)iterator.next();
bw.write(s.toString());//这里如果只需要微博内容可以bw.write(s.getText());
bw.newLine();
bw.flush();
}
}catch(WeiboException e){
e.printStackTrace();
System.out.println(e);
}catch(FileNotFoundException e){
e.printStackTrace();
}catch(IOException e){
e.printStackTrace();
}finally{
try {
bw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
获取当前登录用户及其所关注用户的最新微博的Java程序如下:(注意注释)为保护隐私运行结果就不贴出来了。
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.Iterator;
import java.util.List;
import weibo4j.Timeline;
import weibo4j.model.Status;
import weibo4j.model.StatusWapper;
import weibo4j.model.WeiboException;
public class E {
public static void main(String[] args) {
String userID="";//这里由于保护隐私请自己填写userID
String token="";//这里由于保护隐私请自己填写token
Timeline t=new Timeline();
t.client.setToken(token);
StatusWapper sw=null;
ListStatus status=null;
BufferedWriter bw=null;
try{
sw=t.getFriendsTimeline();
status=sw.getStatuses();
bw=new BufferedWriter(new OutputStreamWriter(new FileOutputStream("D:\\friends_status.txt"),"gbk"));
IteratorStatus iterator=status.iterator();
Status s=null;
while(iterator.hasNext()){
s=(Status)iterator.next();
bw.write(s.toString());//这里如果只需要微博内容可以bw.write(s.getText());
bw.newLine();
bw.flush();
}
}catch(WeiboException e){
e.printStackTrace();
System.out.println(e);
}catch(FileNotFoundException e){
e.printStackTrace();
}catch(IOException e){
e.printStackTrace();
}finally{
try {
bw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
急急急!! 手机java版新浪微博发微博总是发送失败,咋办。???
可能是系统内部的问题~建议你从新下一下软件,,,这样可以保证你的系统安全~或许是你的手机出现了问题~
如果觉得会打得不错,请给悬赏分。。谢谢~
网站栏目:java代码发送微博 微博转发代码
标题网址:http://scyanting.com/article/hhidij.html