开发者

Pull images from twitter tweets

As the Title reads, I want something like this:

if the tweet contains a link to an image(yfrog) then make a <img> with that link in src="".

How can i do this?

-- Update --

Okey so what I've come up with so far is that i should make a function consisting "return this.replace", just like Chris Coyier did with links:

String.prototype.linkify = function() {
    return this.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+/, function(m) {
        return m.link(m);
    }); 
};

But I can't find a way to write a proper function for my need.

Again, what i want: If the string contains a word (for example instagram) select whole "word" (in this case http://...) and put it in src="" at an <img> tag.

-- Update 开发者_如何学Python2 --

http://dev.twitter.com/pages/tweet_entities

I've got a feeling that i can make use of that media_url variable. Can I achieve it through JSON, which I'm using now to get the tweet's text? $.getJSON('http://twitter.com/status/user_timeline/username.json?count=10&callback=?' ... {


If twitter supplies this information, you would have to set include_entities=true.

The real URLs are located in the entities <urls> section. Then you will have to get the compose the thumbnail url yourslef and add it in src.


You can pull images from the twitter api by passing the right params. Here is an example: https://api.twitter.com/1/statuses/media_timeline.json?offset=0&count=100&score=true&is_event=false&filter=false&include_entities=true&user_id=18099844&callback=jsfunc

Further go to the twitter photogallery example: https://twitter.com/#!/F_i/media/slideshow?url=pic.twitter.com%2FbdeUOxcO

Look at the requests made in firebug.

From there it should help you refine the data if it should come from yfrog.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜