Webserivce only accepts requests from local server

Asked

Viewed 97 times

2

I have a Webservice in PHP and need to use 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 a long time to answer and when it answers the answer comes blank.

For example: page search.php in 127.0.0.1 sends a request to Ws, it returns the data.

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

You know what it can be?

  • Is Webservice local, the webservice client local, or both? And when you use web domain you are talking about the server or client?

1 answer

2


serve from where the request comes 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());

        }

Browser other questions tagged

You are not signed in. Login or sign up in order to post.