0

谁能告诉我如何在 javascript 函数中验证 Foursquare URL。

我们已经通过调用 ajax 调用 graph api 来验证 facebbok URL。四方有没有这样的api。

请帮我解决这个问题。

4

2 回答 2

0
function ajaxCallToValidateFoursquare(){
    var CLIENT_ID = "xxxxxxxxxxx";
    var CLIENT_SECRET = "xxxxxxxxxx";
    var foursquareUrl="https://foursquare.com/v/mh31-headquarters/4e4d100a52b1075a63924a4a"
    var validFoursquareUrl = "foursquare.com/";
    if($("#foursquareUrl").val()!=null && $("#foursquareUrl").val() != ""){
        if(foursquareUrl.indexOf(validFoursquareUrl) != -1){
            var placeName=foursquareUrl.substring(foursquareUrl.lastIndexOf("/")+1);
            var questionIndex = placeName.indexOf("?");
            if(questionIndex > 0)
                placeName = placeName.substring(0, questionIndex);
            $.getJSON('https://api.foursquare.com/v2/venues/'+placeName+'?client_id='+CLIENT_ID+'&client_secret='+CLIENT_SECRET+'&v='+new Date().format("yyyymmdd"),function(data){
                //get Response in JSON - data
            });

        }

    }
}

这里的 clientid 和 secretkey 是您来自foursquare 的应用信息。Date.format 方法返回当前秒数。

于 2012-09-03T07:17:54.863 回答
0

没有用于验证foursquare URL 的foursquare API。

于 2012-08-31T14:22:32.447 回答