Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

HttpWebRequest on Twitter Without API's to FOLLOW a person [HELP]

Hi all, i'm currently working on a twitter bot, but for some reasons, i can't figure out a working code with webrequest with which i can follow someone.
Currently i can login and store cookies from that action, but then i try to POST a request to
Code
https://twitter.com/i/user/follow

with the exact token and the exact username they require, but i get the error which tells me that my account isn't enabled to do that action. Below the code:

Code
request = DirectCast(HttpWebRequest.Create("https://twitter.com/i/user/follow"), HttpWebRequest)
    Dim Post2 As String = "authenticity_token=" & Token & "&user_id=707602308"
    Dim PostData2 As Byte() = Encoding.UTF8.GetBytes(Post2)
    With request
    .Method = "POST"
    .CookieContainer = cc
    .UserAgent = "Mozilla/5.0 (Windows NT 5.1; rv:14.0) Gecko/20100101 Firefox/14.0.1"
    .Accept = "application/json, text/javascript, */*; q=0.01"""
    .Referer = "https://twitter.com/Gr0wlit"
    .ContentType = "Content-Type: application/x-www-form-urlencoded; charset=UTF-8"
    .KeepAlive = True
    .ContentLength = PostData2.Length
    Dim str As Stream = .GetRequestStream
    str.Write(PostData2, 0, PostData2.Length)
    str.Close()
    End With
    res = DirectCast(request.GetResponse, HttpWebResponse)
    cc.Add(res.Cookies)
    source = New StreamReader(res.GetResponseStream).ReadToEnd
    res.Close()

where req is the httpwebrequest and cc is cookiecontainer. Where is the error?
Is the account you are following with email confirmed?
(Jan 28, 2013 10:35 AM)FlynCow Wrote:  Is the account you are following with email confirmed?

Yes of course. It is e-mail confirmed.
i assume, you toked a wrong token or didnt put the logininfos in the cookiecontainer the right way
(Jan 28, 2013 03:44 PM)li0nsar3c00l Wrote:  i assume, you toked a wrong token or didnt put the logininfos in the cookiecontainer the right way

I've done all correctly, since the token is the same of the token i use to login, and all is stored on the same cookiecontainer.
Use the html request would take forever. Just use a php script, you could easily follow with 1000 accounts under 2 minutes. and since it uses the api + mobile version u can't get banned.
(Jan 29, 2013 09:15 AM)bobsmith Wrote:  Use the html request would take forever. Just use a php script, you could easily follow with 1000 accounts under 2 minutes. and since it uses the api + mobile version u can't get banned.

Can you explain better what you are trying to say please?
looks like your missing a couple of headers...

Code
(Request-Line)    POST /i/user/follow HTTP/1.1
Host    twitter.com
User-Agent    Mozilla/5.0 (Windows NT 6.2; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0
Accept    application/json, text/javascript, */*; q=0.01
Accept-Language    en-US,en;q=0.5
Accept-Encoding    gzip, deflate
DNT    1
Content-Type    application/x-www-form-urlencoded; charset=UTF-8
x-use-list-items    true
X-Requested-With    XMLHttpRequest
Referer    https://twitter.com/followers
Content-Length    76
Cookie    guest_id=v1%3A135291996445975367; k=10.35.53.138.1359164203211156; _twitter_sess=BAh7EDoJdXNlcmkEk1lhAiIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6%250ARmxhc2g6OkZsYXNoSGFzaHsABjoKQHVzZWR7ADoTcGFzc3dvcmRfdG9rZW4w%250AOhBzdGF5X3NlY3VyZVQ6D2NyZWF0ZWRfYXRsKwi2mNGKPAE6G3Nlc3Npb25f%250AcGFzc3dvcmRfdG9rZW4wOgxjc3JmX2lkIiU4MWJkNTQ5NjE5M2NmMmJmMjQy%250AMDk2ZmE3NzQ2NTA1NjoVaW5fbmV3X3VzZXJfZmxvdzA6E3Nob3dfaGVscF9s%250AaW5rMDoHaWQiJWFjZDM4OTRmMzlhN2U5ZTZhMjNhOTIyOThhMWU2M2U1Og5y%250AZXR1cm5fdG8iImh0dHBzOi8vdHdpdHRlci5jb20vZm9sbG93ZXJz--69443135df66281234c9dd0f78a3733f1e11275c; original_referer=padhuUp37zi4XoWogyFqcGgJdw%2BJPXpx; auth_token=ccaffbba788860186c4c74de46d3938b7b76ce4e; auth_token_session=true; secure_session=true; twid=u%3D39934355%7C8teCmXJgvtKF%2FCTIY7fgH%2Bl0UvU%3D; twll=l%3D1359538679; remember_checked=0; lang=en; h=%7B%22newer_tweet_id%22%3A%22296552663280140288%22%2C%22promoted_content%22%3A%7B%22social_context%22%3A%5B%7B%22id%22%3A133265485%2C%22screen_name%22%3A%22SOFTBABY__%22%2C%22name%22%3A%22SoftBaby%5Cu00ae%22%7D%2C%7B%22id%22%3A35968135%2C%22screen_name%22%3A%22DWO34%22%2C%22name%22%3A%22David+Ohara%22%7D%2C%7B%22id%22%3A35277676%2C%22screen_name%22%3A%22newps3games%22%2C%22name%22%3A%22The+Gamer+%28Max%29%22%7D%5D%2C%22impression_id%22%3A%224568f8647a3d3652%22%2C%22disclosure_text%22%3A%22%22%2C%22disclosure_type%22%3A%22promoted%22%7D%2C%22older_tweet_id%22%3A%22296552602093633536%22%2C%22tweet_id%22%3A%22296016793426862080%22%7D
Connection    keep-alive
Pragma    no-cache
Cache-Control    no-cache

make sure your mimicking the exact packet but with replacing the changing values you need to post. also, make sure your sending all the cookies needed.

what i learned best is to just create an html file with the response string and above everything have the request and response headers.
(Jan 29, 2013 09:34 AM)Gr0wlit Wrote:  Can you explain better what you are trying to say please?

The token from your login is different from the tokens on every page. Every new page generates a new token.
(Jan 30, 2013 03:56 AM)Alien. Wrote:  The token from your login is different from the tokens on every page. Every new page generates a new token.
(Jan 28, 2013 03:44 PM)li0nsar3c00l Wrote:  i assume, you toked a wrong token or didnt put the logininfos in the cookiecontainer the right way

thats what i thought too. its a bit annoying to grab the token....


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C#] by HardStoNMay 2, 2021 12:59 AM 5 269 May 2, 2021 12:59 AM
Last Post: vaiperboy
[C#] by elmagekJan 2, 2020 02:04 PM 1 174 Jan 2, 2020 02:04 PM
Last Post: tkuczyn
[C#] by draxyeeSep 10, 2019 01:37 PM 12 389 Sep 10, 2019 01:37 PM
Last Post: MavenGradle