Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
cURL/wp#u remote#u post:won';不能在wordpress插件中工作_Wordpress_Plugins_Curl - Fatal编程技术网

cURL/wp#u remote#u post:won';不能在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

我正在开发一个wordpress插件,它通过一个cURL post调用从另一个站点提取数据。我已经在wordpress插件和wordpress的outsite中测试了相同的代码

wordpress外部脚本工作正常,但在wordpress插件内部,脚本无法工作:

Wordpress插件:

$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:\