XMLRPC 无法在本地主机上运行
大家好,我已经在 WordPress 主题上工作了一段时间了,当它在我的服务器上时一切正常,但是当我在本地计算机上加载它时,我无法使用某些功能,即从在管理面板之外。为此,我使用 XMLRPC 和以下代码 -
$params = array(0,$username,$password,$content,true);
$request = xmlrpc_encode_request('metaWeblog.newPost',$params);
$ch = curl_init();
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
curl_setopt($ch, CURLOPT_URL, $rpcurl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 1);
$results = curl_exec($ch);
curl_close($ch);
传递的参数都是有效且正确的,但我就是无法弄清楚我的生活出了什么问题。任何帮助将不胜感激。
Hey guys, I've been working on a Wordpress theme for a while now and all works fine when it's on my server, but when I load it up on my machine locally I am unable to utilise certain functionality, namely the ability to post from outside the admin panel. To do this I use XMLRPC and the following code -
$params = array(0,$username,$password,$content,true);
$request = xmlrpc_encode_request('metaWeblog.newPost',$params);
$ch = curl_init();
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
curl_setopt($ch, CURLOPT_URL, $rpcurl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 1);
$results = curl_exec($ch);
curl_close($ch);
The params passed are all valid and correct, and I just cannot figure out what is wrong for the life of me. Any help would be much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据您的故障点...听起来您的本地计算机尚未完全设置。如果 PHP 在失败之前到达
xmlrpc_encode_request
,那么 PHP 可能会工作,但是php.ini
设置是否正确,并且XML-RPC
库已启用?更新:
您需要从该行中删除分号:
Based on your fail point... sounds like your local machine isn't completely setup. Presumably PHP works if it gets to
xmlrpc_encode_request
before failing, but isphp.ini
setup correctly, and theXML-RPC
library enabled?Update:
You need to remove the semi-colon from the line:
您是否尝试过查看 $results 变量的响应是什么? $rpcurl 变量是否设置为正确的 URL?
Have you tried seeing what the response from the $results variable is? Is the $rpcurl variable set to the right URL?