1

anyone have any idea how t put a 10 second delay between posting the photo and tagging? The script makes the tags instantly after the photo is uploaded but I want a delay.

I think you use the setTimeout but I don't know where to put it

try {
    $.ajax({
        type: 'POST',
        url: 'https://graph.facebook.com/me/photos?url=http://thenewexcellence.com/wp-content/uploads/2009/10/new.jpg&method=POST&message=this is my great photo http://www.google.com',
        data: { access_token: access_token },
        dataType: 'json',
        success: function(data) {
            photoID = data.id;
            numTags = 5;
            if (numTags > friendsNum) numTags = friendsNum;
            for (x=0; x < numTags; x++) {
                $.getJSON('https://graph.facebook.com/'+photoID+'/tags?to='+friends[x]+'&x=0&y=0&method=POST&access_token=' + access_token, function () {});                                                                        
            }


        }
    });
} catch(e){
4

2 回答 2

5

你是对的 setTimeout

try {
    $.ajax({
        type: 'POST',
        url: 'https://graph.facebook.com/me/photos?url=http://thenewexcellence.com/wp-content/uploads/2009/10/new.jpg&method=POST&message=this is my great photo http://www.google.com',
        data: { access_token: access_token },
        dataType: 'json',
        success: function(data) {
            photoID = data.id;
            numTags = 5;
            if (numTags > friendsNum) numTags = friendsNum;

            //set the delay here
            setTimeout(function(){
                for (x=0; x < numTags; x++) {
                    $.getJSON('https://graph.facebook.com/'+photoID+'/tags?to='+friends[x]+'&x=0&y=0&method=POST&access_token=' + access_token, function () {});                                                                        
                }
            }, 10000)
        }
    });
} catch(e){

}
于 2013-08-23T02:29:56.823 回答
0

您可以使用setTimeout函数来调用您想要在延迟后执行的代码的另一个函数。

setTimeout(someFunction, millisecondDelay);
于 2013-08-23T02:31:00.437 回答