我有一个代码可以在 word press 上发布数据,即-
String username = "xyz";
String password = "xyz";
String xmlRpcUrl = "http://www.arrestcentral.com/xmlrpc.php?";
Wordpress wp = new Wordpress(username, password, xmlRpcUrl);
Page recentPost = new Page();
String result = wp.newPost(recentPost, true);`
这些相同的代码工作了 2 个月,但现在不工作了。 现在当我去发布数据时显示异常即-
redstone.xmlrpc.XmlRpcException: The response could not be parsed.
at redstone.xmlrpc.XmlRpcClient.handleResponse(Unknown Source)
at redstone.xmlrpc.XmlRpcClient.endCall(Unknown Source)
at redstone.xmlrpc.XmlRpcClient.invoke(Unknown Source)
at redstone.xmlrpc.XmlRpcProxy.invoke(Unknown Source)
at net.bican.wordpress.$Proxy1.newMediaObject(Unknown Source)
at net.bican.wordpress.Wordpress.newMediaObject(Wordpress.java:582)
at WordpressPost.DataWordpressPost.DataPost(DataWordpressPost.java:53)
at arrestcentral.ArrestData.readPdf(ArrestData.java:420)
at arrestcentral.ArrestData.main(ArrestData.java:447)
Caused by: java.io.FileNotFoundException: http://www.arrestcentral.com/XMLrpc.php?
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1478)
... 9 more'
我正在使用
xmlrpc-client-1.1
WordPress 3.2.1
最佳答案
http://www.arrestcentral.com/XMLrpc.php
(如堆栈跟踪中所示)不存在并返回 404 错误。将该 URL 放入您的浏览器中,您就会看到。这正是您所期望的。
http://www.arrestcentral.com/xmlrpc.php
另一方面 确实 存在,如果您不带参数请求它,您将返回:
XML-RPC server accepts POST requests only.
您需要使用正确的 url (http://www.arrestcentral.com/xmlrpc.php
) 没有结尾的问号:
String xmlRpcUrl = "http://www.arrestcentral.com/xmlrpc.php";
关于java - 在 wordpress post 中获取异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7122248/