Scott
Scott

Reputation: 285

Extract text value from aspx via php

Trying to get a text value either "yes" or "no" from an aspx page via my php product page.

from here..

after code= i need to insert the product model number $products_model

example.. http://www.madisonb2b.co.uk/stockenquiry.aspx?id=B8FxKDnJ%2bIdaPT1Nw5wo4r87qHuHcCQIPZzeUE%2fI36LIFOM%2bayBi2RSXHzIJS5Hj97JNSyYL80Q%3d&code=RN311014

replace RN311014 with $products_model and then echo back the text result

hope someone can help..

thanks scott

i tryed this within my orginal code

<?php $contents = file_get_contents("http://www.madisonb2b.co.uk/stockenquiry.aspx?id=B8FxKDnJ%2bIdaPT1Nw5wo4r87qHuHcCQIPZzeUE%2fI36LIFOM%2bayBi2RSXHzIJS5Hj97JNSyYL80Q%3d&code={$products_model}", NULL, NULL, 0, 3); echo $contents;

Blockquote

Upvotes: 0

Views: 1160

Answers (3)

digiwombat
digiwombat

Reputation: 16

The other two posted solutions will only work if allow_url_fopen has been enabled, which it likely hasn't.

http://www.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen

Lots of hosts and PHP builds won't have it enabled for various reasons.

You can either change it in your php.ini or use a CURL request, which would really be the better way about it, ASSUMING CURL is enabled on your PHP install.

$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, 'http://www.madisonb2b.co.uk/stockenquiry.aspx?id=B8FxKDnJ%2bIdaPT1Nw5wo4r87qHuHcCQIPZzeUE%2fI36LIFOM%2bayBi2RSXHzIJS5Hj97JNSyYL80Q%3d&code=<CODE GOES HERE LADIES>');
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1) ;
$contents = curl_exec ($ch);
curl_close ($ch);

echo $contents;

That should work... probably. It'll get you close enough anyway. Haha.

Upvotes: 0

Joseph
Joseph

Reputation: 1963

The problem is that it is not just text that is returned. There is HTML there as well (view source). You need to pull the first line out of the file that is returned as well. For example:

$contents = file_get_contents("http://www.madisonb2b.co.uk/stockenquiry.aspx?id=B8FxKDnJ%2bIdaPT1Nw5wo4r87qHuHcCQIPZzeUE%2fI36LIFOM%2bayBi2RSXHzIJS5Hj97JNSyYL80Q%3d&code={$products_model}", NULL, NULL, 0, 3);

echo $contents;

Upvotes: 0

Sourabh
Sourabh

Reputation: 4765

try using

$value=file_get_contents('http://www.madisonb2b.co.uk/stockenquiry.aspx?id=B8FxKDnJ%2bIdaPT1Nw5wo4r87qHuHcCQIPZzeUE%2fI36LIFOM%2bayBi2RSXHzIJS5Hj97JNSyYL80Q%3d&code=<code>');

echo $value;

you can also consider using "PHP Curl"

Upvotes: 1

Related Questions