Dynamic timeline selection for embedded timelines - Hashtag Timeline

北战南征 提交于 2019-12-08 14:37:54

问题


I've followed the guide here to add multiple widgets using the same widget id and this works perfectly fine for User timeline.

Snippet ----

<a class="twitter-timeline" href="https://twitter.com/benward" data-widget-id="[id]" data-screen-name="benward">
<a class="twitter-timeline" href="https://twitter.com/endform" data-widget-id="[id]" data-screen-name="endform">
<a class="twitter-timeline" href="https://twitter.com/kang" data-widget-id="[id]" data-screen-name="kang">
<a class="twitter-timeline" href="https://twitter.com/brianellin" data-widget-id="[id]" data-screen-name="brianellin">

What i would want to do is do the same( show different widgets ) for multiple hashtags - #MH17 , #MH370 on the same page. But these tags change for each article on a page.

I want to know if either of these are possible.

  1. Make the same guide available for search query to this and this without creating a widget manually from twitter page. Timeline changes when i change the "data-screen-name" property. Is there something like "data-hashtag-name" ?
  2. Use twitter API or something to automate the process of creating widget from the browser using Auth Token - Secret ?

回答1:


May be this help you . Here i am sending you some example using this I am get json and render html div

Here is a sample code and demo you can use for search in twitter

1) http://www.codexworld.com/create-custom-twitter-widget-using-php/

2)you can also look into this examle may be this will full fill your requirement . http://dev.kim-maida.com/twitter/

3) here is demo code and code sample link. https://github.com/kmaida/twitter-timeline-php




回答2:


did you see these pages?

https://dev.twitter.com/web/embedded-timelines/search

https://twitter.com/settings/widgets/new/search

You can do this:

corgi is the sample hashtag:

<a class="twitter-timeline" href="https://twitter.com/hashtag/corgi" data-widget-id="612280670367301632">#corgi Tweets</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>


来源:https://stackoverflow.com/questions/25446833/dynamic-timeline-selection-for-embedded-timelines-hashtag-timeline

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!