0
Posted on 1:02 AM by Softminer and filed under
C#
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace WebApplication1.DateOfWeek { public partial class WebForm1 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string ret = GetStringFromWeek(); } private string GetStringFromWeek() { var d = DateTime.Now; System.Globalization.CultureInfo cul = System.Globalization.CultureInfo.CurrentCulture; var firstDayWeek = cul.Calendar.GetWeekOfYear( d, System.Globalization.CalendarWeekRule.FirstDay, DayOfWeek.Monday); int weekNum = cul.Calendar.GetWeekOfYear( d, System.Globalization.CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday); int year = weekNum == 52 && d.Month == 1 ? d.Year - 1 : d.Year; switch(weekNum) { case 4: return "MA"; case 5: return "MB"; case 6: return "MB"; case 7: return "MB"; case 8: return "MB"; case 9: return "MB"; case 10: return "MB"; case 11: return "MB"; case 12: return "MB"; case 13: return "MB"; case 14: return "MB"; case 15: return "MB"; case 16: return "MB"; case 17: return "MB"; case 18: return "MB"; case 19: return "MB"; case 20: return "MB"; case 21: return "MB"; case 22: return "MB"; case 23: return "MB"; case 24: return "MB"; case 25: return "MB"; case 26: return "MB"; case 27: return "MB"; case 28: return "MB"; case 29: return "MB"; case 30: return "MB"; case 31: return "MB"; case 32: return "MB"; case 33: return "MB"; case 34: return "MB"; case 35: return "MB"; case 36: return "MB"; case 37: return "MB"; case 38: return "MB"; case 39: return "MB"; case 40: return "MB"; case 41: return "MB"; case 42: return "MB"; case 43: return "MB"; case 44: return "MB"; case 45: return "MB"; case 46: return "MB"; case 47: return "MB"; case 48: return "MB"; case 49: return "MB"; case 50: return "MB"; case 51: return "MB"; case 52: return "MB"; default: return "Default"; } return "test"; } private string GetDayoFWeek() { switch (DateTime.Now.DayOfWeek) { case DayOfWeek.Friday: return "F"; case DayOfWeek.Monday: return "M"; case DayOfWeek.Saturday: return "S"; case DayOfWeek.Sunday: return "M"; case DayOfWeek.Thursday: return "T"; case DayOfWeek.Tuesday: return "E"; case DayOfWeek.Wednesday: return "W"; } return "NO"; } } }
0
How to generate long life access token
1. First you need to create an App, for creating app go to https://developers.facebook.com
From menu App, choose Add a new app
when you created app you will have a App ID and App Secret key
2. Gerenerating short access token which is 1 hour valid
From menu choose Tools -> Access Token
then you have the "User Token"
3. Call facebook Api
Go to Tools-> Graph API explorer
for example /me?fields=id,name
would be https://graph.facebook.com/me?fields=id,name&access_token={access_token}
4. To generate 2 months valid access token, use following get request
https://graph.facebook.com/oauth/access_token? grant_type=fb_exchange_token& client_id={app-id}& client_secret={app-secret}& fb_exchange_token={short-lived-token}
app-id you get from step 1
app-secret you get from step 1
short-lived-token you get from step 2
5. Long life valid token
$facebook->api("/PAGE_ID?fields=access_token");
related links +
Posted on 2:58 AM by Softminer and filed under
Facebook
How to generate long life access token
1. First you need to create an App, for creating app go to https://developers.facebook.com
From menu App, choose Add a new app
when you created app you will have a App ID and App Secret key
2. Gerenerating short access token which is 1 hour valid
From menu choose Tools -> Access Token
then you have the "User Token"
3. Call facebook Api
Go to Tools-> Graph API explorer
for example /me?fields=id,name
would be https://graph.facebook.com/me?fields=id,name&access_token={access_token}
4. To generate 2 months valid access token, use following get request
https://graph.facebook.com/oauth/access_token? grant_type=fb_exchange_token& client_id={app-id}& client_secret={app-secret}& fb_exchange_token={short-lived-token}
app-id you get from step 1
app-secret you get from step 1
short-lived-token you get from step 2
5. Long life valid token
$facebook->api("/PAGE_ID?fields=access_token");
related links +