How to display video content based on country

Discussion in 'PHP' started by ksonia90, Aug 11, 2014.

  1. #1
    is there any php code example that i can refer to display video content based on country? i want to display certain video for china's users
     
    ksonia90, Aug 11, 2014 IP
  2. HuggyStudios

    HuggyStudios Well-Known Member

    Messages:
    724
    Likes Received:
    20
    Best Answers:
    26
    Trophy Points:
    165
    #2
    HuggyStudios, Aug 12, 2014 IP
  3. abhicyco

    abhicyco Active Member

    Messages:
    36
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    75
    #3
    You can get the IP address of the client as below

    if(!empty($_SERVER['HTTP_CLIENT_IP'])){
    $ip = $_SERVER['HTTP_CLIENT_IP'];} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
    $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];}else{
    $ip = $_SERVER['REMOTE_ADDR'];}

    Then using api like http://www.hostip.info/use.html you can get the country name/country code and on the basis of that you can show the video content

    Other Free api are
    http://ipinfodb.com/ip_location_api.php
    http://www.ipgeo.com/api/
    http://ip2.cc/
    http://www.geobytes.com/IpLocator.htm
     
    abhicyco, Aug 21, 2014 IP
  4. abhicyco

    abhicyco Active Member

    Messages:
    36
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    75
    #4
    Other Alternative is
    1) Get the IP address of client
    2) download ip-tables (http://dev.maxmind.com/geoip/legacy/geolite/)
    3) Check with your requirement and display the video
     
    abhicyco, Aug 21, 2014 IP
  5. ksonia90

    ksonia90 Greenhorn

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #5
    thanks Abhicyco!! :D
     
    ksonia90, Aug 21, 2014 IP
  6. abhicyco

    abhicyco Active Member

    Messages:
    36
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    75
    #6
    Welcome.. :)
     
    abhicyco, Aug 22, 2014 IP