WordPress.org

Support

Support » Plugins and Hacks » [Resolved] [Plugin: Songkick Concerts and Festivals] How to show concerts from…

[Resolved] [Plugin: Songkick Concerts and Festivals] How to show concerts from…

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author saleandro
    Member

    @saleandro

    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!

    asianxjay
    Member

    @asianxjay

    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

    Plugin Author saleandro
    Member

    @saleandro

    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

    asianxjay
    Member

    @asianxjay

    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!

    Plugin Author saleandro
    Member

    @saleandro

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

    asianxjay
    Member

    @asianxjay

    You mean the username link or the API key?

    Plugin Author saleandro
    Member

    @saleandro

    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!

    asianxjay
    Member

    @asianxjay

    It worked! Thank you so much!

    Plugin Author saleandro
    Member

    @saleandro

    great 🙂

    Plugin Author saleandro
    Member

    @saleandro

    Closing this case.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘[Resolved] [Plugin: Songkick Concerts and Festivals] How to show concerts from…’ is closed to new replies.