Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- header('Control-Allow-Origin: *');
- header('Access-Control-Allow-Origin: *');
- $url = 'http://www.russianpost.ru/autotarif/Autotarif.aspx';
- $params = '?viewPost=26&countryCode=643&typePost=1';
- $params .= '&weight=' . $_GET['weight'];
- $params .= '&value1=' . $_GET['value1'];
- $params .= '&postOfficeId=' . $_GET['postOfficeId'];
- $html = file_get_contents($url.$params);
- preg_match('/<input id="key" name="key" value="([0-9]+)"\/>/', $html, $matches);
- if ($matches) {
- $context = stream_context_create(array(
- 'http' => array(
- 'method' => 'POST',
- 'header' => 'Content-Type: application/x-www-form-urlencoded' . PHP_EOL,
- 'content' => 'key=' . $matches[1],
- ),
- ));
- $html = file_get_contents($url, false, $context);
- }
- preg_match('/<span id="lblErrStr">(.*)<\/span>/', $html, $error);
- if (!empty($error[1])) {
- echo $error[1];
- } else {
- preg_match('/<span id="TarifValue">([0-9,]+)<\/span>/', $html, $result);
- echo str_replace(',', '.', $result[1]);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement