Reputation: 13651
I'm creating a mobile payment processing script for my site, and to validate the payment I have to grab a string from the providers site.
The string will be either "Valid" or "Invalid"
How can I pull this string from my own site?
Upvotes: 0
Views: 1749
Reputation: 21007
There's many methods, you can use file_get_contents( 'http://...')
, curl
or open socket
directly.
I'd go with curl, It'll give you best control with minimum amount of code.
Upvotes: 3
Reputation: 1454
If you want to check for a particular string in the HTML from a remote page based on the URL, you can use the following:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://some.url.com");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
if (strstr($output, "Valid")) {
// The payment is valid
}
else {
// The payment is invalid
}
Hope that helps.
Upvotes: 1