
Note the lines that appear like php8.0-* are often extensions for PHP of course the version should correspond with the version of PHP you got installed. This returns a list of packages that you can install. Libapache2-mod-php8.0 - server-side, HTML-embedded scripting language (Apache 2 module) libphp8.0-embed - HTML-embedded scripting language (Embedded SAPI library) php8.0 - server-side, HTML-embedded scripting language (metapackage) php8.0-amqp - AMQP extension for PHP php8.0-apcu - APC User Cache for PHP php8.0-ast - AST extension for PHP 7 php8.0-bcmath - Bcmath module for PHP php8.0-bz2 - bzip2 module for PHP php8.0-cgi - server-side, HTML-embedded scripting language (CGI binary) php8.0-cli - command-line interpreter for the PHP scripting language php8.0-common - documentation, examples and common module for PHP php8.0-curl - CURL module for PHP php8.0-dba - DBA module for PHP php8.0-dev - Files for PHP8.0 module development Both can be set using the curl_setopt function,Ī simple POST request is performed as follows:

We need to do two things to send a post request, set the CURLOPT_POST option to true, and include the post fields via the CURLOPT_POSTFIELDS option. When sending a POST request with cURL, you should beware that providing the post fields in an array is likely to cause problems in some cases, as it will cause cURL to send the request as multipart/form-data with a boundary, instead of sending it as application/x-www-form-urlencoded – this is rather unexpected behavior. The CURLOPT_POSTFIELDS option is also used when sending POST requests. Responses to a HEAD request can not contain a message body. The basic idea behind the cURL functions is that you initialize a cURL session using the curlinit(), then you can set all your options for the transfer via the curlsetopt(), then you can execute the session with the curlexec() and then you finish off your session using the curlclose().

Sending a message body with a GET is valid according to the the specification. Once you've compiled PHP with cURL support, you can begin using the cURL functions. I managed to solve this by adding the following into my functions.$ch = curl_init ( "" ) $payload = '' curl_setopt ( $ch, CURLOPT_POSTFIELDS, $payload ) curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true ) // Perform the request, and save content to $result $result = curl_exec ( $ch ) // Shows the result! echo $result What am I doing wrong here? Can anyone assist pleaseĪlso is there a specific place I should be running the script? Page template? Functions.php? A Plugin?Įventually I will need to grab the current logged in users username and a custom user meta field and put this data into here Īnd then I will need to format the XML into php when its returned so I can then I can do things with the data. Nothing happens and the Error_log comes back empty $reci = wp_remote_retrieve_body( $result ) $body = wp_remote_retrieve_body( $response ) $response = wp_remote_post( $url, $args ) 'headers' => array( '', 'cache-control' => 'no-cache',

I tried to change this into wordpress $url = '' This first attempt some what works outside of wordpress $curl = curl_init() ĬURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,ĬURLOPT_POSTFIELDS => "\r\n username\r\n 123456789\r\n Hello\r\n\r\n",

I am working on a script to bring in an xml file from another server via Post request, This would then return another xml of data which I can then store into a wordpress database depending on certain values.
