我需要通过他们的API自动将消息发布到craigslist.org.
以下是craigslist发布API的最新参考资料(2013年12月2日更新):http: //www.craigslist.org/about/bulk_posting_interface
他们有一个非常好的干净API,唯一的问题似乎是你必须提供的cl:auth元素:
<cl:auth username="listuser@bogus.com" password="p0stp@rty" accountID="14"/>
Run Code Online (Sandbox Code Playgroud)
他们将accountID描述为:具有足够块信用(或开票帐户)的craigslist帐号,其中提供的用户名是此accountID的授权买家.
我在craigslist.org上找不到任何定价信息或详细信息.
如何授权我的帐户发布消息?如何获得有效的帐户ID?
我正在尝试使用jQuery UI自动完成功能来制作Google自动填充服务的包装器(因为我只想以Google API无法实现的方式限制Google返回的某些结果).
假设我有这个代码:
$("#address").autocomplete({
source: function(request, response){
autoCompleteService = new google.maps.places.AutocompleteService();
autoCompleteService.getQueryPredictions({input: request.term }, autocompleteCallback);
//I should somewhere call the "response" object with desired suggestions as arguments
},
minLength: 5,
});
Run Code Online (Sandbox Code Playgroud)
问题是jQuery UI Autocomplete强制我调用"响应"对象(实际上是一个函数),并提供我想作为参数向用户显示的建议.
但是,另一方面,Google API强制我定义一个回调函数(在我的情况下是'autocompleteCallback'),它在完成后将请求的建议作为参数提供给谁.
当然,我不能在'autocompleteCallback'函数中调用'response'对象,我也不能在这行之后调用响应对象:
autoCompleteService.getQueryPredictions({input: request.term }, autocompleteCallback);
Run Code Online (Sandbox Code Playgroud)
因为JS是异步的,我不能确定我得到的东西让我们说:我用来传递结果的全局变量.
那会是什么解决方案?对于像这样的问题,有一个众所周知的JS设计模式吗?