10金币
你好,我现在用C#编辑,近期的任务是通过连接Twitter API,使推特上的信息加载到form中。现在可以通过填写用户名的keyword把信息加载到spread的用户名列中。也可以通过填写内容的keyword把信息加载到spread的内容列中。
现在的问题是1.如何通过填写点赞数或者转发数,按搜索btn时能够搜索到最新的点赞数或转发数相同的内容。 问题2.如何通过编辑时间范围,搜索到对应期间的消息内容。
谢谢
现在可以实现用户名列的代码是这样的
public async void btnSearch_ClickAsync(object sender, EventArgs e)
{
string json = "";
var keyword = TxtUserKeyword.Text;
//var iine = UDGoodNum.Value;
var tokens = CoreTweet.Tokens.Create("x5zlbPoZc1J8L6Yqs",//API key
"gkvmkdweVptkMgCahNZv1gQY",//API secret key
"qwDFygt9OTDaHyFnxrVFx0uRA1I",//Access token
"VcaeyQJfUOPawvtTa9m");//Access token secret
try
{
fpSpread1_Sheet1.ClearRange(0, 0, 30, 5, false);
string Icon2 = "";
string User2 = "";
string Tweet2 = "";
int? Favorite2 = null;
int? Retweet2 = null;
var p = new FpSpread();
int i = 0;
List<string> json_list = new List<string>();
var parm = new Dictionary<string, object>(){
// { "q", keyword },
{ "count", 100 },
{ "screen_name", keyword },
};
//var result = await tokens.Search.TweetsAsync(parm);
var tweets = await tokens.Statuses.UserTimelineAsync(parm);
};
// var twee = await tokens.Statuses.RetweetsAsync(parm1);
foreach (var tweet in tweets)
{
if (i < 30)
{
try
{
Icon2 = tweet.User.ProfileImageUrl;
User2 = tweet.User.ScreenName;
Tweet2 = tweet.Text;
Favorite2 = tweet.FavoriteCount;
Retweet2 = tweet.RetweetCount;
WebClient wc = new WebClient();
Stream stream = wc.OpenRead(tweet.User.ProfileImageUrl);
Bitmap bitmap = new Bitmap(stream);
fpSpread1_Sheet1.Cells[i, 0].Value = bitmap;
}
catch (Exception)
{
Icon2 = null;
User2 = tweet.User.ScreenName;
Tweet2 = tweet.Text;
Favorite2 = tweet.FavoriteCount;
Retweet2 = tweet.RetweetCount;
fpSpread1_Sheet1.Cells[i, 0].Value = null;
}
int? num = tweet.RetweetCount;
Console.WriteLine(num.ToString());
Console.WriteLine("{0}: {1}\n{2}:{3}:{4}",
tweet.User.Name, tweet.Text, tweet.FavoriteCount, tweet.RetweetCount, tweet.CreatedAt.LocalDateTime);
Console.WriteLine("---------");
fpSpread1_Sheet1.Cells[i, 1].Value = tweet.User.Name;
fpSpread1_Sheet1.Cells[i, 2].Value = tweet.Text;
fpSpread1_Sheet1.Cells[i, 3].Value = tweet.FavoriteCount;
fpSpread1_Sheet1.Cells[i, 4].Value = tweet.RetweetCount;
i++;
using (var ms = new MemoryStream())
using (var sr = new StreamReader(ms))
{
// var serializer = new DataContractJsonSerializer(typeof(FpSpread));
// serializer.WriteObject(ms, p);
// ms.Position = 0;
// json += sr.ReadToEnd();
}
}
}
Height_Reset();
|
|