Search code examples
phpzend-frameworkrestcurlzend-http-client

How to use zend_http_client or curl in right way


I'm using zend_http_client. What i want is to send a request to transfer(without redirecting) to another site and send number in field that I have and get the answer with info i need to use on my site. That's what i'm doing, but how to send my number to that field and submit it?

 $url = 'http://gdeposylka.ru/';
                        $config = array(
                            'timeout' => 30
                        );
                        $client = new Zend_Http_Client($url, $config);
                        try {
                            $response = $client->request('GET');
                            if ($response->getStatus() == 200) {
                                $ctype = $response->getHeader('Content-type');
                                $body = $response->getBody();
                                $dom = new Zend_Dom_Query($body);
                                $results = $dom->query('limit');
                                $item->site_k = 1 + (int) $results->current()->textContent;
                                var_dump($response);
                                exit;
                            }
                        } catch (Zend_Http_Client_Adapter_Exception $e) {

                        }

Thanks and sorry for grammar mistakes.


Solution

  • Because there is a hash on the site you're trying to send a request, you probably wont be able to get this done. Hash mechanism makes it impossible to send request straight to the URL stated in action param of form tag. It's designed particulary to prevent such action you want to make. Still, since there is no captcha you can try web automation.

    What you might find useful is ie. Selenium http://docs.seleniumhq.org/