Link to home
Start Free TrialLog in
Avatar of daz1234
daz1234

asked on

how to excute a script to show on a webpage

i have a script that which when run from a browser url it returns the requested info
rwebsite.aspx?dialplan=004477909999

how can i create a webpage that a user enter the above dialplan in an input field and submits the request. the results return and the viewed

Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

You would use an HTML form to receive the data string that goes into the URL.  Then you would use CURL or file_get_contents to send the completed URL to the rwebsite.aspx script.  Can you give us the actual URL you want to use?  I can give you a code example.
Avatar of daz1234
daz1234

ASKER

Thanks, this shows how that might be used to call the ecocaller web service.
<?php // RAY_temp_daz1234.php
error_reporting(E_ALL);


// FROM THE ORIGINAL POST AT EE
// rwebsite.aspx?dialplan=004477909999


// THE FULLY QUALIFIED URL OF THE WEB SERVICE WE WANT TO TALK TO
$url = 'https://www.ecocaller.com/secure/ratewebsite.aspx?dialplan=';

// DEFAULT VALUES ARE EMPTY
$dat = NULL;

// IF THERE IS DATA CALL THE WEB SERVICE
if (!empty($_GET["d"]))
{
    $dat = $_GET["d"];
    $url = $url . $dat;
    $htm = file_get_contents($url);

    // SHOW WHAT CAME BACK
    echo htmlentities($htm);
}


// END OF PHP PROCESSING - DROP INTO HTML TO PUT UP THE FORM
?>
ENTER THE PHONE NUMBER LIKE "004477909999"
<form>
<input name="d" value="<?php echo $dat; ?>" />
<input type="submit" />
</form>

Open in new window

See line 23.  You may want to "tidy up" the returned data string.  You might also want to contact ecocaller and find out if they have an API.

HTH, ~Ray
Avatar of daz1234

ASKER

Hi Ray,

Line 23 echo htmlentities($htm); is not returning anything. Any thoughts?
Avatar of daz1234

ASKER

The returned string shoud show like below:

Ireland-Mobile-Vodafone Rate 0.0745 £/min
Ireland-Mobile-Vodafone Rate 0.0871 €/min
Ireland-Mobile-Vodafone Rate 0.1199 $/min
Try that script on my server.  It may be that your host has disabled your ability to get to foreign web services.  If that is the case, get a new host.
http://www.laprbass.com/RAY_temp_daz1234.php?d=004477909999
Let's try the code this way.  Where is ecocaller.com hosted?
<?php // RAY_temp_daz1234.php
error_reporting(E_ALL);


// FROM THE ORIGINAL POST AT EE
// rwebsite.aspx?dialplan=004477909999


// THE FULLY QUALIFIED URL OF THE WEB SERVICE WE WANT TO TALK TO
$url = 'https://www.ecocaller.com/secure/ratewebsite.aspx?dialplan=';

// DEFAULT VALUES ARE EMPTY
$dat = NULL;

// IF THERE IS DATA CALL THE WEB SERVICE
if (!empty($_GET["d"]))
{
    $dat = $_GET["d"];
    $url = $url . $dat;
    $htm = file_get_contents($url);

    if (!$htm) echo "<br/>WEB SERVICE AT $url FAILED";

    // SHOW WHAT CAME BACK
    echo htmlentities($htm);
}


// END OF PHP PROCESSING - DROP INTO HTML TO PUT UP THE FORM
?>
ENTER THE PHONE NUMBER LIKE "004477909999"
<form>
<input name="d" value="<?php echo $dat; ?>" />
<input type="submit" />
</form>

Open in new window

Sidebar note... Not sure if you're responsible for standards compliance, but this is worth a look.  My colleagues are telling me that standards are more and more important every day, especially in mobile apps.
http://validator.w3.org/check?uri=https%3A%2F%2Fwww.ecocaller.com%2F&charset=%28detect+automatically%29&doctype=Inline&group=0
Avatar of daz1234

ASKER

Hi Ray

can you send me a copy of your RAY_temp_daz1234.php as its failing everytime on my side

now i have access to the host files
Use the code snippet at ID:35069308.  That is EXACTLY what is showing at this URL.
http://www.laprbass.com/RAY_temp_daz1234.php?d=004477909999
Avatar of daz1234

ASKER

can you test from your side my script

https://www.ecocaller.com/testchecker5.php
Please post the code for your script, thanks.  When I run it I get this message:
WEB SERVICE AT https://www.ecocaller.com/secure/ratewebsite.aspx?dialplan=004477909999 FAILED

That is not what you want, but the answer may be really simple.  As I wrote above, If that [failure] is the case, get a new host.
Avatar of daz1234

ASKER

Do you think it's a configuration on the iis stopping it from working
Avatar of daz1234

ASKER

copy of file

<?php // testchecker5.php
error_reporting(E_ALL);


// FROM THE ORIGINAL POST AT EE
// rwebsite.aspx?dialplan=004477909999


// THE FULLY QUALIFIED URL OF THE WEB SERVICE WE WANT TO TALK TO
$url = 'https://www.ecocaller.com/secure/ratewebsite.aspx?dialplan=';

// DEFAULT VALUES ARE EMPTY
$dat = NULL;

// IF THERE IS DATA CALL THE WEB SERVICE
if (!empty($_GET["d"]))
{
    $dat = $_GET["d"];
    $url = $url . $dat;
    $htm = file_get_contents($url);

    if (!$htm) echo "<br/>WEB SERVICE AT $url FAILED<br/>";

    // SHOW WHAT CAME BACK
    echo htmlentities($htm);
}


// END OF PHP PROCESSING - DROP INTO HTML TO PUT UP THE FORM
?>
<html><body>
ENTER THE PHONE NUMBER LIKE "004477909999"
<form>
<input name="d" value="<?php echo $dat; ?>" />
<input type="submit" />
</form>
</body></html>
Please explain how you solved this problem instead of deleting it, thanks.
Avatar of daz1234

ASKER

I was deleting a different question

Did I delete this one

I'm bad
No prob - stuff happens.
Avatar of daz1234

ASKER

I still can't figure out why I can't run it on my side
Let me try this question one last time before I sign off and recommend you stop work and hire a professional:  From ID:35069308... Where is ecocaller.com hosted?
Avatar of daz1234

ASKER

I think the problem is that if I am running the script from on the same server directory its the URL the issue
Again: From ID:35069308... Where is ecocaller.com hosted?
Avatar of daz1234

ASKER

because you can access the command from external its a routing hosting issue

how would you set the url to take from within the same directory on the website
What is so hard about answering my simple question?  Please help me help you.  For the last time, Again: From ID:35069308... Where is ecocaller.com hosted?
Avatar of daz1234

ASKER

its hosted on my servers isp verizon
Thank you.  Is it a dedicated server or a shared server?
Avatar of daz1234

ASKER

dedicated
Good.  Please install this little script and post a link to it here.  You can take it down after we get a chance to look at the settings.
<?php phpinfo();

Open in new window

Avatar of daz1234

ASKER

sorry for not getting back sooner
Avatar of daz1234

ASKER

i can run your script from another physical server location and it works fine

when i run locally it doesn't
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of daz1234

ASKER

CURL FAIL: https://www.ecocaller.com/secure/ratewebsite.aspx?dialplan=004477909999 TIMEOUT=5, CURL_ERRNO=28array(20) {
  ["url"]=>
  string(71) "https://www.ecocaller.com/secure/ratewebsite.aspx?dialplan=004477909999"
  ["content_type"]=>
  NULL
  ["http_code"]=>
  int(0)
  ["header_size"]=>
  int(0)
  ["request_size"]=>
  int(0)
  ["filetime"]=>
  int(-1)
  ["ssl_verify_result"]=>
  int(0)
  ["redirect_count"]=>
  int(0)
  ["total_time"]=>
  float(0)
  ["namelookup_time"]=>
  float(0)
  ["connect_time"]=>
  float(0)
  ["pretransfer_time"]=>
  float(0)
  ["size_upload"]=>
  float(0)
  ["size_download"]=>
  float(0)
  ["speed_download"]=>
  float(0)
  ["speed_upload"]=>
  float(0)
  ["download_content_length"]=>
  float(-1)
  ["upload_content_length"]=>
  float(-1)
  ["starttransfer_time"]=>
  float(0)
  ["redirect_time"]=>
  float(0)
}
NO https://www.ecocaller.com/secure/ratewebsite.aspx
Please see this page.
http://curl.haxx.se/libcurl/c/libcurl-errors.html

CURL error #28 is a timeout.  Consider raising the timeout parameter, maybe to 15 or 20, to see if the script has time to respond.  

If that does not work, then I have to expect that something in /secure/ratewebsite.aspx is deliberately reacting differently to calls from local and remote URLs.   I would never design a program that way, but maybe someone did?
Avatar of daz1234

ASKER

iis for ecocaller domain is redirecting

port 80 to port 81 with forced SSL could that be the cause
Why?  How does that help things?
Avatar of daz1234

ASKER

its was configured that way because of IIS 6

to redirect all normal http to https
But is there some reason for doing that?  Why not use the protocol that is requested by the client?  That would seen to make sense to me.

Regarding ID:35139821 -- did you try a longer timeout?
Avatar of daz1234

ASKER

no difference still timeout same error
Then I have to expect that something in /secure/ratewebsite.aspx is deliberately reacting differently to calls from local and remote URLs.  I think we have exhausted what we can do without seeing that script.  Suggest you post a new question in the ASP Zone with the source code for that script.  You would probably want to post a link to this question, too, so anyone seeing the new question can see what we have pursued on this side.
Avatar of daz1234

ASKER

thanks for all your effort and help
You're welcome.  It will be interesting to see what that script is doing differently when it encounters different clients!