Closed davidbauer closed 11 years ago
Before I continue on this, can someone please have a look at what I've done so far. I'm not really sure if it makes sense to have two different variables myUser
vs myHashtag
based on what the user enters into the search field.
Or is it easier to always store the input in the same variable, irrespective of whether its a username or a hashtag? (and perhaps add something like myInput.type
with either "hashtag" or "user" in it?
Just had a look at the script again. It seems to me it makes more sense to just store the input from the form as myInput
(instead of myUser
that we use now) and make use if/else statements based on myInput[0] == "#"
as we proceed.
Do you agree, @backflip @dergraf?
Sounds reasonable.
I'd suggest to only check for myInput[0] == "@" to switch to search by user. So all requests not starting with an "@" would by default be treated as a search by phrase. As it technically doesn't make any difference (as fas as I remember) whether you are searching by hashtag or any other phrase of choice, I don't see the need to force the user by an additional check to use a hashtag.
@oliverwehn The point here is that most people will enter usernames without the "@". We don't want to treat those as normal search queries. I think it's more intuitive to enter a hashtag with prefix "#". I see your point as it opens up the possibility to use any search phrase, but I don't think forcing users to enter usernames with an "@" is the right solution.
Ok, got your point. Just thought a Twitter-related application should stick to the Twitter-like “notation habits”, as a lot of its users will also be Twitter users. Maybe setting the input field's placeholder attribute to e.g. “@username, #hashtag or phrase” would help here.
Yes, I agree. But my experience is that whenever you ask people for their Twitter username, they don't know whether to enter it with or without "@". That's why I'd like to catch both cases. Also: I see usernames and hashtags as the more common usecases for this tool. But let's see what people think. We can always evolve (and the more coding I have to do, the better :-))
Right. ;) BTW: Nice work so far!
Did some more work on that. Can anyone tell me what this error (when calling the search API) means?
XMLHttpRequest cannot load http://search.twitter.com/search.json?q=%23ddj&include_entities=true&include_rts=false&since_id=1&count=100. Origin http://labs.davidbauer.ch is not allowed by Access-Control-Allow-Origin.
For security reasons browsers don't allow you to request content from other domains (cross-domain). That's where JSONP comes in. But to force the Twitter API to deliver response data using the JSONP format, you have to provide the callback parameter with each API request. I've already fixed it and sent you a pull request.
using the search api