创建一个Word preSS后与XMLRPC和jQuery创建一个、Word、preSS、XMLRPC

2023-09-10 19:41:38 作者:咒

我有一个动态的页面,用户可以填补一些领域。这些用户都将有一个词preSS博客的帐户。我想,让他们直接张贴在网页,博客上生成的内容。我不希望存储密码在服务器上,所以我想这样做,客户端使用jQuery。

I have a dynamic page where the user can fill some fields. Those users will all have an account on a WordPress blog. I would like to allow them to directly post the content generated by the webpage to the blog. I don't want to store their password in the server so I want to do this client-side with JQuery.

我已经在标准 jQuery.post 方法和的 RPC插件但我没有设法使他们的工作。例如,我最新的尝试是这样的:

I have looked both at the standard jQuery.post method and the rpc plugin but I didn't manage to make them work. For example, my latest attempts were something like this:

wprpc = $.rpc('http://blog.wordpress.com/xmlrpc.php', 'xml', callback);
function callback(server) {
    answer = server.newPost(0,'user','pass','<struct><title>TestRPC</title></struct>');
    alert(answer);
}

和绝望之一:

$.post('http://blogurl.com/xmlrpc.php', { blogid: 0, username: "user", password: "pass", struct: "<struct><title>Test</title></struct>" }, function(data) {alert(data);}, 'xml');

但它静静地失败(回调甚至不叫)。

but it silently failed (the callback is not even called).

你会怎么做呢?

推荐答案

虽然出身政策将你绊倒道格指出,你可以有一台服务器后的结果,另外,一种代理的脚本。这是一个黑客位,但它会工作。我个人使用PHP和卷曲做到这一点。

While the origin policy will trip you up as Doug pointed out, you could have a script on one server post the results to the other, a sort of proxy. It's a bit of a hack, but it'd work. I'd personally use PHP and cURL to do it.