我正在使用blackbaud API,它说我需要将post数据发送到url以接收我想要的XML数据。
参考资料:https://www.blackbaud.com/files/support/helpfiles/FAFAPI/default.htm
我不太确定如何做到这一点,所以我使用了jQuery的POST方法并获得了跨域错误:
请求的资源上没有“访问-控制-允许-源”头。
下面是我用来发送请求的代码:
$(document).ready(function() {
$.post("https://www.kintera.org/api/Authentication/Login.ashx?accountid=xxxxx",
{username: "xxxxxx", password:"xxxxxxx"},function(result) {
console.log(result);
});
})这里有人能把我引向正确的方向吗?当我对页面进行简单的php发布时,就会显示xml结果,我只是不知道如何才能获得这些信息供我自己使用。建议?
我遇到的最大问题是跨域错误
编辑:弄明白了。对于任何有同样问题的人,这里是我使用curl的解决方案。
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.kintera.org/api/Authentication/Login.ashx?accountid=xxxxxxx");
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array('username' => $username,'password' => $password)));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
$xml = new SimpleXMLElement($result);
curl_close($ch);https://stackoverflow.com/questions/21471364
复制相似问题