I'm using RestSharp to make a call to the Facebook API and it's returning the App Access Token.
However I need to return the User Access Token instead as I need this to create offline conversion sets using the Marketing API.
I've given the app all the appropriate permissions and I can verify this using the Access Token Tool.
Can someone help? Thanks
public void getToken(string uriauth, string clientid, string client_secret, string redirect_uri)
{
RestSharp.Deserializers.JsonDeserializer deserial = new RestSharp.Deserializers.JsonDeserializer();
var client = new RestClient(uriauth);// + "?client_id=" + clientid + "&client_secret=" + client_secret + "&grant_type=client_credentials");
var request = new RestRequest(Method.POST);
//request.Resource = "{request_string}";
request.AddHeader("cache-control", "no-cache");
request.AddHeader("content-type", "text/javascript; charset=utf-8");
request.AddParameter("application/x-www-form-urlencoded", "grant_type=client_credentials&client_id=" + clientid + "&client_secret=" + client_secret, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
if (response.Content.ToString().Contains("access") == false)
{
try
{
throw new System.Exception("Token API doesn't work");
}
catch (Exception ex)
{
Dts.Events.FireError(0, "ERROR", ex.Message, null, 0);
Dts.TaskResult = (int)ScriptResults.Failure;
return;
}
}
else
{
Token returnData = deserial.Deserialize<Token>(response);
if (returnData.access_token != null)
{
access_token = returnData.access_token;
}
}
}
决定在Facebook中生成用户令牌并将其通过SSIS变量传递到我的C#脚本中
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.