cURL/wp#u remote#u post:won';不能在wordpress插件中工作
我正在开发一个wordpress插件,它通过一个cURL post调用从另一个站点提取数据。我已经在wordpress插件和wordpress的outsite中测试了相同的代码 wordpress外部脚本工作正常,但在wordpress插件内部,脚本无法工作: Wordpress插件:cURL/wp#u remote#u post:won';不能在wordpress插件中工作,wordpress,plugins,curl,Wordpress,Plugins,Curl,我正在开发一个wordpress插件,它通过一个cURL post调用从另一个站点提取数据。我已经在wordpress插件和wordpress的outsite中测试了相同的代码 wordpress外部脚本工作正常,但在wordpress插件内部,脚本无法工作: Wordpress插件: $handle = curl_init(); curl_setopt($handle, CURLOPT_URL, $url); curl_setopt($handle, CURLOPT_R
$handle = curl_init();
curl_setopt($handle, CURLOPT_URL, $url);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_POST, true );
curl_setopt($handle, CURLOPT_FOLLOWLOCATION, true );
curl_setopt($handle, CURLOPT_POSTFIELDS, array('postfield' => 'postfieldcontent'));
$result = curl_exec($handle);
主要地点:
mysql_query("INSERT INTO table (q, w, e, r, t, y, u) VALUES ('', '".$_POST[postfield]."', '', '', '', '', '')");
出于调试目的,我已删除了所有数据库安全性。我也试过wp_remote_post功能,但也不起作用。我甚至尝试了wp_remote_get函数,但我可以访问get变量:
$result = wp_remote_get( 'http://qwerty.dk/folder/filename.php?getfield=qwertrert' );
我已经放弃了-请帮助:)
致意
Kim您需要在php.ini文件中启用cURL。看
wp\u remote\u post()
POST方法将适用于类WP\u Http\u Curl
,但不适用于类WP\u Http\u Streams
(Curl回退)
另一种方法是使用wp\u remote\u get()
尝试curl\u setopt($handle,CURLOPT\u POSTFIELDS,'postfield=postfieldcontent')代码>你好,萨法罗夫,谢谢你的输入,但它不起作用。好像没有发送postfield:\