Its driving me mad.
Ok guys this is driving me crazy.
I have done a little php and I like it but I have this problem.
I know how to pass data by url and receive it from the url with GET and POST.
But now I have a url specifically.
http://dendritics.com/scales/metal-calc ... D&Markup=0
If you load this page to browser it will give the current price of silver in $AUD/ ounce However I don’t want to load the page in the browser. I just want to get the price to work with in my own page.
In just html an Iframe will load the URL like so
<iframe src="http://dendritics.com/scales/metal-calc ... D&Markup=0" width="70%" height="270">
<p>Your browser does not support iframes.</p>
</iframe>
However if I use php to try to get a value like so
<?php
$_GET = "http://dendritics.com/scales/metal-calc ... D&Markup=0";
echo $_GET;
$v1 = $_GET['WeightU'];
$v2 = $_GET['Units'];
$v3 = $_GET['Metal'];
$v4 = $_GET['PurityC'];
$v5 = $_GET['CurrencyN'];
$v6 = $_GET['PrOzt'];
echo "Variable One Value: $v1 <br>
Variable Two Value: $v2 <br>
Variable Two Value: $v3 <br>
Variable Two Value: $v4 <br>
Variable Two Value: $v5 <br>
Variable Two Value: $v6 ";
?>
It runs ok but will not give me the values it comes back with a list like this .
Variable Two Value: h
Variable Two Value: h
Variable Two Value: h
Variable Two Value: h
Variable Two Value: h
Where in Gods name is it getting all the hs from ?????
I don’t want the page loaded in an I fram or a browser I just want the price value to work with .
How can I do this .
Please help O wize ones.
Its driving me mad.
Moderator: General Moderators
-
internet-solution
- Forum Contributor
- Posts: 220
- Joined: Thu May 27, 2010 6:27 am
- Location: UK
Re: Its driving me mad.
It seems you are trying to crawl the other website to get info. One of the ways to do is to use curl for this. There are crawling classes available on internet (Google php crawl script or php spider script) which you can use to do this.
You cannot use GET or POST for that. These REQUEST variables are meant for getting the http request to the page running the script.
Regarding the hs - its the first character of your $_GET variable, i.e. http://......
You cannot use GET or POST for that. These REQUEST variables are meant for getting the http request to the page running the script.
Regarding the hs - its the first character of your $_GET variable, i.e. http://......
Re: Its driving me mad.
Ok I appreciate the education.
So I used curl like so .
<?php
$data = "<soap:Envelope>[...]</soap:Envelope>";
$tuCurl = curl_init();
curl_setopt($tuCurl, CURLOPT_URL, "http://dendritics.com/scales/metal-calc ... D&Markup=0");
curl_setopt($tuCurl, CURLOPT_PORT , 443);
curl_setopt($tuCurl, CURLOPT_VERBOSE, 0);
curl_setopt($tuCurl, CURLOPT_HEADER, 0);
curl_setopt($tuCurl, CURLOPT_SSLVERSION, 3);
curl_setopt($tuCurl, CURLOPT_SSLCERT, getcwd() . "/client.pem");
curl_setopt($tuCurl, CURLOPT_SSLKEY, getcwd() . "/keyout.pem");
curl_setopt($tuCurl, CURLOPT_CAINFO, getcwd() . "/ca.pem");
curl_setopt($tuCurl, CURLOPT_POST, 1);
curl_setopt($tuCurl, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($tuCurl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($tuCurl, CURLOPT_POSTFIELDS, $data);
curl_setopt($tuCurl, CURLOPT_HTTPHEADER, array("Content-Type: text/xml","SOAPAction: \"/soap/action/query\"", "Content-length: ".strlen($data)));
$tuData = curl_exec($tuCurl);
if(!curl_errno($tuCurl)){
$info = curl_getinfo($tuCurl);
echo 'Took ' . $info['total_time'] . ' seconds to send a request to ' . $info['url'];
} else {
echo 'Curl error: ' . curl_error($tuCurl);
}
curl_close($tuCurl);
echo $tuData;
?>
Now it comes back and says
Curl error: Empty reply from server
What is it trying to tell me.???
So I used curl like so .
<?php
$data = "<soap:Envelope>[...]</soap:Envelope>";
$tuCurl = curl_init();
curl_setopt($tuCurl, CURLOPT_URL, "http://dendritics.com/scales/metal-calc ... D&Markup=0");
curl_setopt($tuCurl, CURLOPT_PORT , 443);
curl_setopt($tuCurl, CURLOPT_VERBOSE, 0);
curl_setopt($tuCurl, CURLOPT_HEADER, 0);
curl_setopt($tuCurl, CURLOPT_SSLVERSION, 3);
curl_setopt($tuCurl, CURLOPT_SSLCERT, getcwd() . "/client.pem");
curl_setopt($tuCurl, CURLOPT_SSLKEY, getcwd() . "/keyout.pem");
curl_setopt($tuCurl, CURLOPT_CAINFO, getcwd() . "/ca.pem");
curl_setopt($tuCurl, CURLOPT_POST, 1);
curl_setopt($tuCurl, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($tuCurl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($tuCurl, CURLOPT_POSTFIELDS, $data);
curl_setopt($tuCurl, CURLOPT_HTTPHEADER, array("Content-Type: text/xml","SOAPAction: \"/soap/action/query\"", "Content-length: ".strlen($data)));
$tuData = curl_exec($tuCurl);
if(!curl_errno($tuCurl)){
$info = curl_getinfo($tuCurl);
echo 'Took ' . $info['total_time'] . ' seconds to send a request to ' . $info['url'];
} else {
echo 'Curl error: ' . curl_error($tuCurl);
}
curl_close($tuCurl);
echo $tuData;
?>
Now it comes back and says
Curl error: Empty reply from server
What is it trying to tell me.???
Re: Its driving me mad.
the server is not responding to your request it looks like.