i am in a middle of developing a facebook asp.net c# application
now the application store the access_token of the users in a database and i olso write my expire time, and facebook id.
for example when a user pass authentication i store in the db a record for the user with his access_token, and expire=DateTime.UtcNow+5 minutes, and his facebook id
now the application run a background Thread every 1 minute.
the Thread checks every user if is expire < DateTime.UtcNow and if so-> it post on it wall i know that the facebook access_token expire in somting like 1 hour
now my problem is that sometimes it's post and sometimes not, it's not steady.
and i make the post in a loop and i use PostAsync.
the code:
for (int i = 0; i < records.Count; i++)
{
//init the facebookClient with valid access_token
Facebook.FacebookClient fbc = new Facebook.FacebookClient(records[i].token_data);
Dictionary<string, object> post = new Dictionary<string, object>();
post.Add("message", "my message");
post.Add("link", "http://mylink/");
post.Add("picture", "http://somepic.gif");
post.Add("name", "my app name");
post.Add("caption", "text text text");
post.Add("description", "text text text");
post.Add("actions", "{\"name\":\"Play Now!\", \"link\":\"http://my app page/\"}");
//the punchline
fbc.PostAsync(records[i].facebook_id.ToString() + "/feed", post);
}
now it cold run 50-100 loops
with my tests f开发者_如何学Goor some users i'ts post and for some not and not all time.
If I understand you correctly, you are sending the same message every time to the user's wall? Your problem may be Facebook. If there is no variation in your message, Facebook tends to ignore the second message (or it may just simply add the phrase "X similar posts").
What you are trying to do sounds very "spammy" from a Facebook perspective (they are very harsh on doing this type of things). If you are writing a message to a user's wall, you really should be asking the user if it's OK to do so (no you don't have to, but it should be done in conjunction with the user's activity on your app.. like posting a game score). If users report that you are spamming their wall, your app will be pulled by Facebook, so you might want to rethink what you are trying to do.
(I doubt this is the answer you wanted to hear, and as a result I doubt you will mark me as an answer, but if your research verifies what I have told you, it would be nice to get marked as the answer.. or at least voted up by another reader).
精彩评论