What I want to do using cURL:
-
Login to my WordPress site, execute my own PHP code and save it to a variable:
$code_to_execute_remotely = wp_create_nonce(‘my_form’);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, ‘www.mywordpresssite.com’);
curl_setopt($ch, CURLOPT_SOMEMYSTERIOUSFUNCTION, $code_to_execute_remotely);
$resulting_variable = curl_exec($ch); -
Then use that variable in a 2nd cURL execution:
curl_setopt($ch, CURLOPT_MYSECONDFUNCTION, $resulting_variable);
$second_ececution = curl_exec($ch);
curl_close($ch);
I’ve used dummy code to simplify things of course. The other functionality (logging into the remote site, etc.) is no problem, just executing that code remotely and returning its results as a usable variable, that’s all I need. Since I’m not terribly familiar w/ cURL, it’s possible I’m attempting something beyond its bounds, in which case I’d be very thankful to know what alternative could achieve this.
On the remote site use the php eval function:
http://php.net/manual/en/function.eval.php
Edit with full explanation:
On your local server:
On the remote server in receiver.php:
Notes: