0

I have to make a method to send my login and password to a website and get the xml it returns, its gonna be a list of products. What would be the best way? My options are: SOAP 1.1, SOAP 1.2, GET and POST? Also, how could I read the xml it returns?

1

Did with Get method, here is the code

    $url = 'http://urlexample';

    $headers = array(
        "Content-type: application/x-www-form-urlencoded",
        "Accept: application/x-www-form-urlencoded"
    );

    $method = 'GET';

    $connection = new Varien_Http_Adapter_Curl();

    if ($method == "GET") {
        $zendMethod = Zend_Http_Client::GET;
    } elseif ($method == "POST") {
        $zendMethod = Zend_Http_Client::POST;
    } elseif ($method == "PUT") {
        $zendMethod = Zend_Http_Client::PUT;

        //ADICIONA AS OPTIONS MANUALMENTE POIS NATIVAMENTE O WRITE NAO VERIFICA POR PUT
        $connection->addOption(CURLOPT_CUSTOMREQUEST, "PUT");
        $connection->addOption(CURLOPT_POSTFIELDS, $body);
    }

    $connection->setConfig(
        array(
        'timeout'   => 30
        )
    );

    $connection->write($zendMethod, $url, '1.0', $headers, $body);
    $response = $connection->read();
    $connection->close();

    $httpCode = Zend_Http_Response::extractCode($response);
    $response = Zend_Http_Response::extractBody($response);


    echo "<textarea>" . $response . "</textarea>" ;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.