WebSerivce only accepts requests from local server [closed]

2

I have a Webservice in PHP and I need to use it to integrate two applications. WS returns in JSON the data I need. The problem is that it returns only the data when the request is made from a local server. If I do the request from any web domain it takes awhile to respond and when it responds the answer comes in blank.

For example: page fetch.php at 127.0.0.1 sends a request to ws, it returns the data.

page search.php on test.com or any other web domain sends a request to the ws it takes and returns blank.

Do you know what it can be?

    
asked by anonymous 09.05.2016 / 20:45

1 answer

2

Check where the request comes from through these codes ... never failed me ..

<?php
        $ip = $_SERVER['SERVER_ADDR'];

        if ($ip == 'ip do servidor local') {
            mysql_connect('localhost','blabla','senha');
            mysql_select_db('bancodedados') or die (mysql_error());
        }
        elseif ($ip == '127.0.0.1') {
            mysql_connect('localhost','blabla
','senha');
            mysql_select_db('bancodedados') or die (mysql_error());
        }
        else {

            mysql_connect('localweb','root','senha');
            mysql_select_db('bandodedados') or die (mysql_error());

        }
    
09.05.2016 / 22:24