Поиск Api в Твиттере от Hashtag - PullRequest
0 голосов
/ 03 мая 2018

Как в мире я могу использовать API Twitter? Все онлайн кажется устаревшим и не работает. Я создал приложение Twitter на портале для разработчиков, получил токены доступа и т. Д. Что мне теперь делать? Я пытаюсь использовать JQuery, чтобы сделать запрос получения AJAX. Но на что я делаю запрос? Их документация полная мусор.

Ответы [ 3 ]

0 голосов
/ 01 августа 2019

Поскольку новый API Twitter требует аутентификации для всех вызовов, даже тех, которые не относятся к конкретной учетной записи, очень трудно выполнять вызовы API напрямую из Javascript.

Однако вы можете использовать TweetJS.com , который предлагает обертку Javascript для API Twitter, которая не требует аутентификации. Поиск по хештегу будет выглядеть следующим образом:

TweetJs.Search("#Music",
function (data) {
    console.log(data);
});
0 голосов
/ 10 августа 2019

Я разместил на github очень простой пример, который должен показать, как взаимодействовать с API твиттеров. Это использует API Twitter, с документацией в https://www.npmjs.com/package/twitter.

Мой проект использует NodeJS и express для вызова API и dotenv для доступа к переменным скрытого ключа в файле конфигурации. Вот репо ниже. https://github.com/scottmilla/Node-Twitter-Starter

0 голосов
/ 03 мая 2018

Пожалуйста, обратитесь к документации

Где это предполагает, что вы можете использовать URL

https://api.twitter.com/1.1/search/tweets.json?q=%23superbowl&result_type=recent

для получения последних твитов с хэштегом superbowl.

Обратите внимание, что # в этом URL был закодирован в %23. Вы можете найти ссылку на эти кодировки здесь .

Из документов вы можете выполнять следующие операции поиска:

Operator                            Finds Tweets...
watching now                        containing both “watching” and “now”. This is the default operator.
“happy hour”                        containing the exact phrase “happy hour”.
love OR hate                        containing either “love” or “hate” (or both).
beer -root                          containing “beer” but not “root”.
#haiku                              containing the hashtag “haiku”.
from:interior                       sent from Twitter account “interior”.
list:NASA/astronauts-in-space-now   sent from a Twitter account in the NASA list astronauts-in-space-now
to:NASA                             a Tweet authored in reply to Twitter account “NASA”.
@NASA                               mentioning Twitter account “NASA”.
politics filter:safe                containing “politics” with Tweets marked as potentially sensitive removed.
puppy filter:media                  containing “puppy” and an image or video.
puppy -filter:retweets              containing “puppy”, filtering out retweets
puppy filter:native_video           containing “puppy” and an uploaded video, Amplify video, Periscope, or Vine.
puppy filter:periscope              containing “puppy” and a Periscope video URL.
puppy filter:vine                   containing “puppy” and a Vine.
puppy filter:images                 containing “puppy” and links identified as photos, including third parties such as Instagram.
puppy filter:twimg                  containing “puppy” and a pic.twitter.com link representing one or more photos.
hilarious filter:links              containing “hilarious” and linking to URL.
puppy url:amazon                    containing “puppy” and a URL with the word “amazon” anywhere within it.
superhero since:2015-12-21          containing “superhero” and sent since date “2015-12-21” (year-month-day).
puppy until:2015-12-21              containing “puppy” and sent before the date “2015-12-21”.
movie -scary :)                     containing “movie”, but not “scary”, and with a positive attitude.
flight :(                           containing “flight” and with a negative attitude.
traffic ?                           containing “traffic” and asking a question.
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...