You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.9 KiB
42 lines
1.9 KiB
using log4net;
|
|
using OT.COM.ArsenalDB;
|
|
using System;
|
|
using System.Collections.Concurrent;
|
|
|
|
namespace CounsellorBL.Helper
|
|
{
|
|
public class APIURLHelper
|
|
{
|
|
private ILog Logger { get; } = LogManager.GetLogger(typeof(APIURLHelper));
|
|
private string ApiVersion { get; set; }
|
|
|
|
public APIURLHelper()
|
|
{
|
|
const string error_information = "API version initial failed";
|
|
|
|
try
|
|
{
|
|
ConcurrentDictionary<string, string> dicSetting = CustomizeDBMgr.SettingData;
|
|
ApiVersion = dicSetting.ContainsKey("FB_API_VERSION") ? dicSetting["FB_API_VERSION"] : "v7.0";
|
|
|
|
if (string.IsNullOrWhiteSpace(ApiVersion)) throw new Exception(error_information);
|
|
}
|
|
catch(Exception ex)
|
|
{
|
|
Logger.Error($"{error_information}, Excepiton: {ex.ToString()}");
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
public string SendMessage(string access_token_) => $"https://graph.facebook.com/{ApiVersion}/me/messages?access_token={access_token_}";
|
|
|
|
public string CheckAccessToken(string access_token_) => $"https://graph.facebook.com/{ApiVersion}/debug_token?input_token={access_token_}&access_token={access_token_}";
|
|
|
|
public string GetUserAccessToken(string user_access_token_, string app_id_, string app_secret) =>
|
|
$"https://graph.facebook.com/{ApiVersion}/oauth/access_token?grant_type=fb_exchange_token&client_id={app_id_}&client_secret={app_secret}&fb_exchange_token={user_access_token_}";
|
|
|
|
public string GetPageAccessToken(string user_id_, string long_lived_user_access_token) => $"https://graph.facebook.com/{ApiVersion}/{user_id_}/accounts?access_token={long_lived_user_access_token}";
|
|
|
|
public string GetGroupPublicDescription(string group_id_, string user_access_token_) => $"https://graph.facebook.com/{ApiVersion}/{group_id_}?access_token={user_access_token_}";
|
|
}
|
|
}
|