{"id":15568701,"url":"https://github.com/phstc/jquery-twitter","last_synced_at":"2025-04-24T00:05:46.453Z","repository":{"id":1266787,"uuid":"1205832","full_name":"phstc/jquery-twitter","owner":"phstc","description":"jQuery Twitter Search Plugin","archived":false,"fork":false,"pushed_at":"2012-12-18T01:42:41.000Z","size":978,"stargazers_count":8,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-24T00:05:40.473Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://pablocantero.com/blog/2010/12/29/jquery-twitter-search-plugin/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phstc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-12-29T14:06:00.000Z","updated_at":"2019-12-24T13:51:05.000Z","dependencies_parsed_at":"2022-08-16T12:50:26.891Z","dependency_job_id":null,"html_url":"https://github.com/phstc/jquery-twitter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phstc%2Fjquery-twitter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phstc%2Fjquery-twitter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phstc%2Fjquery-twitter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phstc%2Fjquery-twitter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phstc","download_url":"https://codeload.github.com/phstc/jquery-twitter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250535098,"owners_count":21446508,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-02T17:20:30.398Z","updated_at":"2025-04-24T00:05:46.418Z","avatar_url":"https://github.com/phstc.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Why?\n\nI found many jQuery Twitter Plugins, but most of them work with searching and displaying the tweets. In the project that I worked the layout to display the tweets was specific. So I couldn't use the plugins' layout.\n\nThe main idea of Twitter Search Plugin is only for tweets search. You will need to implement the layout to display the tweets.\n\n## What's the difference \n\nThe available plugins on the internet use an ugly syntax to search:\n\n```javascript\n  $.twitter.search({from: 'pablocantero', text: 'hello+world', container: 'myDivId'});\n```\n\n### Twitter Search Plugin is DSL based\n\n```javascript\n  var tweets = new Twitter.tweets();\n  tweets.containing('hello')\n\t.and('world')\n\t.from('pablocantero)\n\t.limit(4)\n\t.order('recent')\n\t.all(function(data){ \n\t\talert(\"It’s a customized function to display the tweets\");\n\t});\n\n```\n\n## The Twitter Search API\n\nThis Plugin follows the Twitter Search API documentation.\n\nTwitter Search API Method: search\nhttp://apiwiki.twitter.com/w/page/22554756/Twitter-Search-API-Method:-search\n\n### Implemented conditions \n\nThe actual conditions were implemented on-demand. If you want a new condition, please have a look at \"Do you want to improve the jQuery Twitter Plugin?\".\n\n * conditions([text or hashtag])\n * and([text or hashtag])\n * or([text or hashtag])\n * from([twitter username])\n * to([twitter username])\n * order([mixed, recent or popular]) - default recent\n * limit([0..100]) - default 100\n * page([page num]) - default 1 \n * locale([locale]) - optional. specify the language of the query you are sending (only ja is currently effective). This is intended for language-specific clients and the default should work in the majority of cases\n\n## Example\n\nThe full example is available on https://gist.github.com/758666\n\n### Import the JavaScript\n\n```html\n  \u003cscript src=\"http://code.jquery.com/jquery-latest.js\"\u003e\u003c/script\u003e\n  \u003cscript type=\"text/javascript\" src#\"https://github.com/phstc/jquery-twitter/raw/master/src/jquery.twitter.js\"\u003e\u003c/script\u003e\n```\n\n### Create success callback\n\nThis plugin is only for tweets search, it does not display the tweets. You need to implement the layout to display the tweets.\n\n```javascript\n\n  /*\n  Customized callback to show the tweets\n  */\n  var tweetsSuccessCallback = function(data){\n  \tvar tweetsLi = '';\n  \tfor(var i = 0; i \u003c data.results.length; i++){\n  \t\tvar tweet = data.results[i];\n  \t\t// Calculate how many hours ago was the tweet posted\n  \t\t// http://www.lupomontero.com/fetching-tweets-with-jquery-and-the-twitter-json-api/\n  \t\tvar dateTweet = new Date(tweet.created_at);\n  \t\tvar dateNow   = new Date();\n  \t\tvar dateDiff  = dateNow - dateTweet;\n  \t\tvar hours     = Math.round(dateDiff/(1000*60*60));\n  \t\ttweetsLi += '\u003cli\u003e \\\n  \t\t      \u003cdl\u003e \\\n  \t\t              \u003cdt\u003e\u003cimg src=\"' + tweet.profile_image_url + '\" /\u003e\u003c/dt\u003e \\\n  \t\t              \u003cdd\u003e \\\n  \t\t                      \u003cspan\u003e\u003ca href=\"http://twitter.com/' + tweet.from_user + '\"\u003e' + tweet.from_user + '\u003c/a\u003e\u003c/span\u003e \\\n  \t\t                      \u003cspan\u003e' + hours + ' hours ago\u003c/span\u003e\u003c/dd\u003e\u003c/dl\u003e \\\n  \t\t      \u003cdiv\u003e' + tweet.text + '\u003c/div\u003e \\\n  \t\t\u003c/li\u003e';\n  \t}\n  \t$('#tweets').html('\u003cul\u003e' + tweetsLi + '\u003c/ul\u003e');\n  }\n```\n\n### Create an error callback\n\nCustomized callback to display an error message\nThis callback is optional, the default error callback shows an alert(errorMessage).\n\n```javascript\n  var tweetsErrorCallback = function(errorMessage, tweet){\n\tvar msg = 'Oops! \\\n\t\t\u003ca href=\"http://dev.twitter.com/pages/rate-limiting\"\u003eTwitter Rate Limit Exceeded\u003c/a\u003e. \\\n\t\tTry again later or search \\\n\t\t\u003ca href=\"http://twitter.com/search?q=' + tweet.toQuery() + '\"\u003edirectly on Twitter\u003c/a\u003e';\n\t$('#tweets').html(msg);\n  }\n```\n\n### Create a search query\n\n```javascript\n  var tweets = Twitter.tweets();\n  tweets.containing('jquery.twitter').all(tweetsSuccessCallback, tweetsErrorCallback);\n```\n\n## Combine OR and FROM queries\n\nThanks to pheze issue/2.\n\nYou can combine OR and FROM queries.\n\n```javascript\n  var tweets = new Twitter.tweets();\n  tweets.containing('jquery-twitter')\n\t.or()\n\t.from('pablocantero')\n\t.all(function(data){ \n\t});\n```\n\nThis query above return all tweets containing 'jquery-twitter', if the result is empty it will return all tweets from @pablocantero\n\n## Test\n\nTo execute the Test suite, just open jquery.twitter-test.html in your browser. The tests were developed with http://docs.jquery.com/Qunit\n\n## Do you want to improve the jQuery Twitter Plugin?\n\nYou’re welcome to make your contributions and send them as a pull request or just send me a message http://pablocantero.com/blog/contato/\n\nhttp://pablocantero.com/blog/2010/12/29/jquery-twitter-search-plugin/\n\nhttp://plugins.jquery.com/project/jquery-twitter\n\n### Contributors\n\nThanks to pheze","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphstc%2Fjquery-twitter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphstc%2Fjquery-twitter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphstc%2Fjquery-twitter/lists"}