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
jack jor
NA
3
3.5k
This request requires matching csrf cookie and header error
May 6 2017 10:56 AM
I can't follow on twitter with my bot anymore!
Twitter changed it's algorithm and now it just uses APIs...
So my new code is like this, and it gives this error:
"
This request requires a matching csrf cookie and header. 353 code error on twitter"
Here's the code:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(
"https://api.twitter.com/1.1/friendships/create.json"
);
request.Accept =
"application/json, text/javascript, */*; q=0.01"
;
request.Headers.Add(
"x-twitter-auth-type"
,
"OAuth2Session"
);
request.Headers.Add(
"x-csrf-token"
, token);
request.Headers.Add(
"X-Twitter-Active-User"
,
"yes"
);
request.Headers.Add(
"Origin"
,
"https://twitter.com"
);
request.Headers.Add(
"Authorization"
,
"Bearer AAAAAAAAAAAAAAAAAAAAAPYXBAAAAAAACLXUNDekMxqa8h%2F40K4moUkGsoc%3DTYfbDKbT3jJPCEVnMYqilB28NHfOPqkca3qaAxGfsyKCs0wRbw"
);
ce.Add(
new
Cookie(
"ct0"
, token) { Domain =
"api.twitter.com"
});
request.Host =
"api.twitter.com"
;
string
postdata =
"challenges_passed=false&handles_challenges=1&include_blocked_by=true&include_blocking=true&include_can_dm=true&include_followed_by=true&include_mute_edge=true&skip_status=true&user_id="
+ datauserid;
request.Method =
"POST"
;
request.Timeout = 10000;
request.UserAgent = useragentMozilla;
request.ContentType =
"application/x-www-form-urlencoded; charset=UTF-8"
;
request.CookieContainer = ce;
request.Referer =
"https://twitter.com/"
;
byte
[] bytes = Encoding.UTF8.GetBytes(postdata);
request.ContentLength = bytes.Length;
Stream stream = request.GetRequestStream();
stream.Write(bytes, 0, bytes.Length);
res = (HttpWebResponse)request.GetResponse();
stream.Close();
res.Close();
I know I'm doing something wrong in this code. I think that Bearer string never changes on twitter, it's always the same. But what is that crsf cookie and header issue. Please help me ASAP.
Maybe if I get the right token from the cookies which is "ct0" in the cookies, and add it to the header as csrf token, it can successfully follow then. But I really don't know how to get a specific cookie with C# httpwebrequest.
Reply
Answers (
0
)
This is my code but result is null.
select row from gridView