Showing posts with label curl. Show all posts
Showing posts with label curl. Show all posts

Thursday, December 12, 2013

php: send xml in post request and read xml in post request

to send xml data in post request using curl:
<?php
        $XMLreq = '<?xml version="1.0" encoding="UTF-8"?>';
        $XMLreq = $XMLreq . '<!DOCTYPE svc_init SYSTEM "http://x.x.x.x/sample.DTD">';
        $XMLreq = $XMLreq . '<svc_init ver="1.0.0">';
        $XMLreq = $XMLreq . '<object>sample</object>';
        $XMLreq = $XMLreq . '</svc_init>';
        $URLreq = "http://x.x.x.x/XMLreceive.php";

        $ch = curl_init($URLreq);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
        curl_setopt($ch, CURLOPT_POSTFIELDS, $XMLreq);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_TIMEOUT, 45);
        $output = curl_exec($ch);
        curl_close($ch);
        echo $output;
?>

to read xml data received in post request:
<?php
        if(isset($HTTP_RAW_POST_DATA))
        {
                echo $HTTP_RAW_POST_DATA;
        }
?>

Tuesday, October 11, 2011

php: curl install

reconfigure your php with:
./configure \
 --with-gd \
 --enable-dbase \
 --enable-module=so \
 --with-png-dir=/usr/lib \
 --enable-so \
 --with-pgsql=/usr/local/pgsql/bin/ \
 --with-apxs2=/usr/local/apache2/bin/apxs \
 --with-config-file-path=/usr/local/apache2/php \
 --with-zlib-dir \
 --with-pear \
 --enable-soap\


# following are added in the config to enable curl
 --with-curl \
 --with-curl-config=/usr/bin/curl-config \
 --with-openssl


# add in /usr/local/lib/php.ini
 extension=php_curl.so

# restart apache web server

# to test, create a php file with the ff content

<?php echo phpinfo(); ?>

CURL:
<?php
 echo '<pre>';
 var_dump(curl_version());
 echo '</pre>';
?>

SSH : No matching host key type found. Their offer: ssh-rsa,ssh-dss

Got this while connecting to my mikrotik router via ssh   Unable to negotiate with <ip address> port <ssh port>: no matching hos...