WordPress.org

Ready to get started?Download WordPress

Forums

Songkick Concerts and Festivals
[resolved] How to show concerts from... (11 posts)

  1. asianxjay
    Member
    Posted 1 year ago #

    Hey!
    I'm trying to figure out how to track concerts from a vistor's ip address? I've seen the variation through here: http://indiecollege.com/
    I'm trying to do it on my website: theergocollective.com
    I saw the Javascript but have no idea how to do that through the plugin for Songkick. Mind you I already have an API key but I want to track visitors ip address and just show the concerts in their area. Any ideas? Thanks!

    http://wordpress.org/extend/plugins/songkick-concerts-and-festivals/

  2. saleandro
    Member
    Plugin Author

    Posted 1 year ago #

    Hi!

    Although Songkick's API allows for that, the WP plugin currently doesn't support getting events by a visitor's IP.

    If you feel like playing around with the code, you can change, for example, the songkick_metro_area_events.php file.
    You can hack the "url" method to return this:
    return "$this->apiurl/events.json?location=clientip&apikey=$this->apikey&per_page=$per_page&page=$page";

    Hope that helps!

  3. asianxjay
    Member
    Posted 1 year ago #

    Hey!
    Thanks for the quick response. I hacked it but for some reason it keeps bringing up Atlanta as my location and clearly I'm in San Francisco. Look here: http://www.theergocollective.com. Any other way to hack it so it corrects itself? Thanks Salesandro!
    Jay

  4. saleandro
    Member
    Plugin Author

    Posted 1 year ago #

    Do you have this ID set in your widget settings: "26330"? This is San Francisco's ID, or SF Bay Area:
    http://www.songkick.com/metro_areas/26330-us-sf-bay-area

  5. asianxjay
    Member
    Posted 1 year ago #

    But wouldn't that mean that the location would track just the SF Bay Area then? I'm trying to have it track the user's IP but it's saying I'm from Atlanta from all computers I"m on. I've tried the hack you typed out but it's defaulting to Atlanta for some reason. Any other ideas? thanks!

  6. saleandro
    Member
    Plugin Author

    Posted 1 year ago #

    Could you post what's the API endpoint (url) you're trying to use?

  7. asianxjay
    Member
    Posted 1 year ago #

    You mean the username link or the API key?

  8. saleandro
    Member
    Plugin Author

    Posted 1 year ago #

    Sorry, I misunderstood you before!

    You have changed the code to use the clientip parameter as I said before? If so, it could be that instead of using the visitor's IP, it's using your server's IP address.

    You could try this instead:
    - get the client's ip address in PHP and then use that to query the API:

    $ip = $_SERVER['REMOTE_ADDR'];
    return "$this->apiurl/events.json?location=ip:$ip&apikey=$this->apikey&per_page=$per_page&page=$page";

    Note that there are probably better and more reliable ways to get a visitor's IP in PHP. I'm sure Google can give you better options :)

    Hope that helps!

  9. asianxjay
    Member
    Posted 1 year ago #

    It worked! Thank you so much!

  10. saleandro
    Member
    Plugin Author

    Posted 1 year ago #

    great :)

  11. saleandro
    Member
    Plugin Author

    Posted 1 year ago #

    Closing this case.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic