Multiple Foursquare 'save' buttons on one page

不想你离开。 提交于 2019-12-04 16:25:46

After inspecting the source of the widgets.js and widgets.asyncbundle.js I discovered that setting thedata-context atribute of the 'Save to Foursquare' button to the ID of the VCard will link these two. Like so:

<div id="hcard-Station-Amsterdam-Centraal" class="vcard">
    <span class="fn">
        <span class="given-name">Station Amsterdam Centraal</span>
    </span>
    <div class="adr">
        <div class="street-address">stationsplein 15</div>
        <span class="locality">Amsterdam</span>, 
        <span class="region">Amsterdam</span> , 
        <span class="postal-code">1012AB</span>
    </div>
</div>
<div id="hcard-Jaarbeursplein" class="vcard">
    <span class="fn">
        <span class="given-name">Jaarbeursplein</span>
    </span>
    <div class="adr">
        <div class="street-address">Jaarbeursplein</div>
        <span class="locality">Utrecht</span>, 
        <span class="region">Utrecht</span>, 
        <span class="postal-code">3521AL</span>
    </div>
</div>

<a href="https://foursquare.com/intent/venue.html" class="fourSq-widget" data-context="hcard-Station-Amsterdam-Centraal" data-variant="wide">Save to foursquare</a>
<a href="https://foursquare.com/intent/venue.html" class="fourSq-widget" data-context="hcard-Jaarbeursplein" data-variant="wide">Save to foursquare</a>

But for the fact that this isn't documented, it may be changed in the near future.

Try this with "data-vid":

 <!-- Place this anchor tag where you want the button to go -->
<br />
All In PartyRadio Studio<a href="https://foursquare.com/intent/venue.html" class="fourSq-widget" data-vid="50575a55e0e27c7feb062116">Save to foursquare</a>
<br />
Sing Sing Music Hall<a href="https://foursquare.com/intent/venue.html" class="fourSq-widget" data-vid="4d47d1fe2165721ebe9ac0d7">Save to foursquare</a>
<br />
Retro Klub<a href="https://foursquare.com/intent/venue.html" class="fourSq-widget" data-vid="4d437d813616b60c2764dac2">Save to foursquare</a>
<br />
Tisza Dokk<a href="https://foursquare.com/intent/venue.html" class="fourSq-widget" data-vid="4f73231de4b0e3a99689cc61">Save to foursquare</a>
<br />
Zöld Zsiráf Kultúrpart<a href="https://foursquare.com/intent/venue.html" class="fourSq-widget" data-vid="4ffad97ef13633933ececa5f">Save to foursquare</a>

<!-- Place this script somewhere after the anchor tag above. If you have multiple buttons, only include the script once. -->
<script type='text/javascript'>
  (function() {
    window.___fourSq = {"uid":"606"};
    var s = document.createElement('script');
    s.type = 'text/javascript';
    s.src = 'http://platform.foursquare.com/js/widgets.js';
    s.async = true;
    var ph = document.getElementsByTagName('script')[0];
    ph.parentNode.insertBefore(s, ph);
  })();
</script>

The in-progress docs for the save-to-foursquare widget are accessible @ https://developer.foursquare.com/overview/widgets. They'll be cleaned up over time, but should be good enough to help this and future widget-related questions =).

In particular, documentation about the "data-context" attribute you need will be pushed to the linked page soon.

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