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

HTMLPHPJavaScript

Avatar of undefined
Last Comment
Ray Paseur

8/22/2022 - Mon
Ray Paseur

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.
daz1234

ASKER
Ray Paseur

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

Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Ray Paseur

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
daz1234

ASKER
Hi Ray,

Line 23 echo htmlentities($htm); is not returning anything. Any thoughts?
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
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Ray Paseur

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
daz1234

ASKER
Ray Paseur

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

All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Ray Paseur

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
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
Ray Paseur

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
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
daz1234

ASKER
can you test from your side my script

https://www.ecocaller.com/testchecker5.php
Ray Paseur

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.
daz1234

ASKER
Do you think it's a configuration on the iis stopping it from working
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
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>
Ray Paseur

Please explain how you solved this problem instead of deleting it, thanks.
daz1234

ASKER
I was deleting a different question

Did I delete this one

I'm bad
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Ray Paseur

No prob - stuff happens.
daz1234

ASKER
I still can't figure out why I can't run it on my side
Ray Paseur

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?
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
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
Ray Paseur

Again: From ID:35069308... Where is ecocaller.com hosted?
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
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Ray Paseur

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?
daz1234

ASKER
its hosted on my servers isp verizon
Ray Paseur

Thank you.  Is it a dedicated server or a shared server?
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
daz1234

ASKER
dedicated
Ray Paseur

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

daz1234

ASKER
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
daz1234

ASKER
sorry for not getting back sooner
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
Ray Paseur

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
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
Your help has saved me hundreds of hours of internet surfing.
fblack61
Ray Paseur

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?
daz1234

ASKER
iis for ecocaller domain is redirecting

port 80 to port 81 with forced SSL could that be the cause
Ray Paseur

Why?  How does that help things?
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
daz1234

ASKER
its was configured that way because of IIS 6

to redirect all normal http to https
Ray Paseur

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?
daz1234

ASKER
no difference still timeout same error
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Ray Paseur

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.
daz1234

ASKER
thanks for all your effort and help
Ray Paseur

You're welcome.  It will be interesting to see what that script is doing differently when it encounters different clients!
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.