0

Hi I'm trying to use Javascript to write a chrome application that will show your last number of tweets but I'm having trouble getting the tweets. I'm a newbie to javascript but I have searched quite a bit and can't find an understandable answer to this.

From chrome and twitter I have the following code.

<script type="text/javascript">
var req = new XMLHttpRequest();
req.open(
"GET",
"https://api.twitter.com/1/statuses/user_timeline.json?
include_entities=true&include_rts=true&screen_name=twitterapi&count=3")
</script> 

This GET request works but how do I use the data it returns with javascript?

2 Answers 2

1

The result is in the req.responseText. You can append it o your document, to see what the response is. It actually depends on what is the response. I mean maybe you need to alert the response, or show it somewhere, or put it in a condition operator and compare with something... Some basoc use:

alert(req.responseText); document.body.innerHTML+=req.responseText;

Sign up to request clarification or add additional context in comments.

Comments

0

It is somewhere in req.responseText. That is, you need to set req.onreadystatechange and once it's ready you'll have it in there.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.