TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Vikash Kumar
NA
959
21.2k
How to get twitter to display more followers
Sep 29 2016 5:55 AM
Hi ,
I ahve tried getting followers from twitter using their REST APIs and two dlls but i only get 20 followers,. Can anyone guide me on this
public partial class GetFollowers : System.Web.UI.Page
{
public string strTwiterFollowers { get; set; }
public string screen_name;
public string url = "https://api.twitter.com/1.1/followers/list.json";
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
findUserFollower(url, screen_name);
}
public void findUserFollower(string resource_url, string screen_name)
{
var oauth_token = "XXXXXXXXXXXXXX";
var oauth_token_secret = "xxxxxxxxxxxxx";
var oauth_consumer_key = "xxxxxxxxxxxx";
var oauth_consumer_secret = "xxxxxxxxxxxxxxx";
// oauth implementation details
var oauth_version = "1.0";
var oauth_signature_method = "HMAC-SHA1";
// unique request details
var oauth_nonce = Convert.ToBase64String(new ASCIIEncoding().GetBytes(DateTime.Now.Ticks.ToString()));
var timeSpan = DateTime.UtcNow
- new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
var oauth_timestamp = Convert.ToInt64(timeSpan.TotalSeconds).ToString();
var baseFormat = "oauth_consumer_key={0}&oauth_nonce={1}&oauth_signature_method={2}"
+ "&oauth_timestamp={3}&oauth_token={4}&oauth_version={5}&screen_name={6}";
var baseString = string.Format(baseFormat,
oauth_consumer_key,
oauth_nonce,
oauth_signature_method,
oauth_timestamp,
oauth_token,
oauth_version,
Uri.EscapeDataString(screen_name)
);
baseString = string.Concat("GET&", Uri.EscapeDataString(resource_url), "&", Uri.EscapeDataString(baseString));
var compositeKey = string.Concat(Uri.EscapeDataString(oauth_consumer_secret),
"&", Uri.EscapeDataString(oauth_token_secret));
string oauth_signature;
using (HMACSHA1 hasher = new HMACSHA1(ASCIIEncoding.ASCII.GetBytes(compositeKey)))
{
oauth_signature = Convert.ToBase64String(
hasher.ComputeHash(ASCIIEncoding.ASCII.GetBytes(baseString)));
}
// create the request header
var headerFormat = "OAuth oauth_nonce=\"{0}\", oauth_signature_method=\"{1}\", " +
"oauth_timestamp=\"{2}\", oauth_consumer_key=\"{3}\", " +
"oauth_token=\"{4}\", oauth_signature=\"{5}\", " +
"oauth_version=\"{6}\"";
var authHeader = string.Format(headerFormat,
Uri.EscapeDataString(oauth_nonce),
Uri.EscapeDataString(oauth_signature_method),
Uri.EscapeDataString(oauth_timestamp),
Uri.EscapeDataString(oauth_consumer_key),
Uri.EscapeDataString(oauth_token),
Uri.EscapeDataString(oauth_signature),
Uri.EscapeDataString(oauth_version)
);
ServicePointManager.Expect100Continue = false;
// make the request
var postBody = "screen_name=" + Uri.EscapeDataString(screen_name);//
resource_url += "?" + postBody;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(resource_url);
request.Headers.Add("Authorization", authHeader);
request.Method = "GET";
request.ContentType = "application/x-www-form-urlencoded";
var response = (HttpWebResponse)request.GetResponse();
//var reader = new StreamReader(response.GetResponseStream());
//var objText = reader.ReadToEnd();
//objText = objText.Replace("\r", "").Replace("\n", "").Replace("\t", "").Replace(",", "~").Replace("}~{", "},{").Replace("\"~\"", "\",\"").Replace("]~", "],").Replace("protected", "").Replace("id_str", "").Replace("verified", ":").Replace("false", "~").Replace("http", ":");
string result = new StreamReader(response.GetResponseStream()).ReadToEnd();
JObject j = JObject.Parse(result);
JArray data = (JArray)j["users"];
int totalFollowers = (data).Count;
lblTotalFollowers.Text = "Your followers are " + (data).Count + "Followers";
if (data != null)
{
List<Twitter_Dot_Net_Rest_Api_Call.twitter_followers.TwiterFollowers> listFollowers = new List<Twitter_Dot_Net_Rest_Api_Call.twitter_followers.TwiterFollowers>();
foreach (var item in data)
{
Twitter_Dot_Net_Rest_Api_Call.twitter_followers.TwiterFollowers objTwiterFollowers = new Twitter_Dot_Net_Rest_Api_Call.twitter_followers.TwiterFollowers();
objTwiterFollowers.ScreenName = item["screen_name"].ToString().Replace("\"", "");
objTwiterFollowers.ProfileImage = item["profile_image_url"].ToString().Replace("\"", "");
objTwiterFollowers.UserId = item["id"].ToString().Replace("\"", "");
listFollowers.Add(objTwiterFollowers);
}
Random objRnd = new Random();
List<Twitter_Dot_Net_Rest_Api_Call.twitter_followers.TwiterFollowers> rendomFollowers = listFollowers.OrderBy(item => objRnd.Next()).ToList<Twitter_Dot_Net_Rest_Api_Call.twitter_followers.TwiterFollowers>();
for (int i = 0; i <= 9; i++)
{
strTwiterFollowers = strTwiterFollowers + "<li><a target='_blank' title='" + rendomFollowers[i].ScreenName + "' href=https://twitter.com/" + rendomFollowers[i].ScreenName + "><img src='" + rendomFollowers[i].ProfileImage + "'/><span>" + rendomFollowers[i].ScreenName + "</span></a></li>";
}
}
}
public class TwiterFollowers
{
public string ScreenName { get; set; }
public string ProfileImage { get; set; }
public string UserId { get; set; }
}
Reply
Answers (
3
)
how to store result of web services into postgresql database
how uddi works in web services