开发者

Facebook / Offline Permission - Trying to perform an action on a set of offline users

开发者 https://www.devze.com 2022-12-28 15:21 出处:网络
We\'re building an app which in part of its functionality tries to capture the number of likes associated to a particular video owned by a user.

We're building an app which in part of its functionality tries to capture the number of likes associated to a particular video owned by a user.

Users of the app are asked for extended off-line access and we capture the key for each user:

The format is like this: 2.hg2QQuYeftuHx1R84J1oGg__.XXXX.1272394800-nnnnnn

Each user has their offline / infinite key stored in a table in a DB. The object_id which we're interested in is also stored in the DB.

At a later stage (offline) we try to run a batch job which reads the number of likes for each user's video. (See attached code)

For some reason however, after the first iteration of the loop - which yields the likes correctly, we get a failure with the oh so familiar message:

"Session key is invalid or no longer valid"

Any insight would be most appreciated.

Thanks,

B

List<DVideo> videoList = db.SelectVideos();

   foreach (DVideo video in videoList)
   {

    long userId = 0;
    ConnectSession fbSession = new ConnectSession(APPLICATION_KEY, SECRET_KEY);
    //session key is attached to the video object for now.
    fbSession.SessionKey =  video.UserSessionKey;
    fbSession.SessionExpires = false;
    string fbuid =video.FBUID;

    long.TryParse(fbuid, out userId);

    if (userId > 0)
    {
     fbSession.UserId = userId;
     fbSession.Login();
     Api fbApi = new Facebook.Rest.Api(fbSession);

     string xmlQueryResult = fbApi.Fql.Query("SELECT user_id FROM like WHERE object_id = " + video.FBVID);

     XmlDocument xmlDoc = new XmlDocument();
     xmlDoc.Load(new StringReader(xmlQueryResult));
     int likesCount = xmlDoc.GetElementsByTagName("user_id").Count;

     //Write entr开发者_JAVA技巧y in VideoWallLikes
     if (likesCount > 0)
     {
      db.CountWallLikes(video.ID, likesCount);
     }

     fbSession.Logout();
    }

    fbSession = null;
   }


You said you have asked user for extended offline access, but by looking at your access token, it is not long-lived. your token is 2.hg2QQuYeftuHx1R84J1oGg__.XXXX.1272394800-nnnnnn, within it, the "1272394800" is expiration epoch time.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号