WordPress.org

Ready to get started?Download WordPress

Forums

Songkick Concerts and Festivals
[resolved] Calling user IP (4 posts)

  1. randymir
    Member
    Posted 1 year ago #

    In a past post someone was trying to have Songkick use the users IP address. You had said to load the below code into their "songkick_metro_area_events.php" file.

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

    I did that and this is now what my file looks like. Not sure if I placed it in the correct place.

    <?php
    require_once dirname(__FILE__) . '/songkick_events.php';
    
    class SongkickMetroAreaEvents extends SongkickEvents {
        public $id;
        public $apikey;
    
        function SongkickMetroAreaEvents($apikey, $id) {
            $this->SongkickEvents($apikey);
            $this->id = trim($id);
        }
    
        function profile_url() {
            return "http://www.songkick.com/metro_areas/$this->id";
        }
    
        protected function url($page, $per_page) {
            $ip = $_SERVER['REMOTE_ADDR'];
    return "$this->apiurl/events.json?location=ip:$ip&apikey=$this->apikey&per_page=$per_page&page=$page";
        }
    }
    
    ?>

    Assuming I have the code right (If I don't please let me know what I did wrong.) How would I call the apikey up in the widget, or as a shortcode?

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

  2. dannyb123abc
    Member
    Posted 1 year ago #

    Hello,

    I too am having difficulty being able to implement this hack. I return no results using the above method.

    Let me know how we both can find solutions to this interesting need.

    Best,

    Dan

  3. saleandro
    Member
    Plugin Author

    Posted 1 year ago #

    randymir: Your code looks right. You can use it as you would to get metro area events. So the shortcode would be:
    [songkick_concerts_and_festivals songkick_id=your_metro_area_id songkick_id_type=metro_area]
    Let me know if it worked!

    dannyb123abc: can you tell me what ip address you're testing with? what does $_SERVER['REMOTE_ADDR'] return?

    ps: sorry for the late reply!

  4. saleandro
    Member
    Plugin Author

    Posted 10 months ago #

    I'm guessing it worked :)
    Marking it as closed for now, let me know if you guys have more questions!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic