Class FacebookClient
- Namespace
- Assembly
- Facebook.dll
Provides access to the Facbook Platform.
public class FacebookClient
- Inheritance
-
FacebookClient
- Inherited Members
Constructors
FacebookClient()
Initializes a new instance of the FacebookClient class.
public FacebookClient()
FacebookClient(string)
Initializes a new instance of the FacebookClient class.
public FacebookClient(string accessToken)
Parameters
accessToken
stringThe facebook access_token.
Exceptions
- ArgumentNullException
Access token in null or empty.
Properties
AccessToken
Gets or sets the access token.
public virtual string AccessToken { get; set; }
Property Value
AppId
Gets or sets the app id.
public virtual string AppId { get; set; }
Property Value
AppSecret
Gets or sets the app secret.
public virtual string AppSecret { get; set; }
Property Value
DefaultVersion
Gets or sets the default graph api version to use when initializing a new instance of FacebookClient.
public static string DefaultVersion { get; set; }
Property Value
IsSecureConnection
Gets or sets the value indicating whether to add return_ssl_resource as default parameter in every request.
public virtual bool IsSecureConnection { get; set; }
Property Value
SubscriptionVerifyToken
Gets or sets the verify_token used in Facebook Realtime updates API.
public virtual string SubscriptionVerifyToken { get; set; }
Property Value
UseFacebookBeta
Gets or sets the value indicating whether to use Facebook beta.
public virtual bool UseFacebookBeta { get; set; }
Property Value
Version
Get or sets the graph api version to use.
public virtual string Version { get; set; }
Property Value
Methods
Api(HttpMethod, string, object, Type)
Makes a request to the Facebook server.
protected virtual object Api(HttpMethod httpMethod, string path, object parameters, Type resultType)
Parameters
httpMethod
HttpMethodHttp method. (GET/POST/DELETE)
path
stringThe resource path or the resource url.
parameters
objectThe parameters.
resultType
TypeThe type of deserialize object into.
Returns
- object
The json result.
ApiTaskAsync(HttpMethod, string, object, Type, object, CancellationToken)
Makes an asynchronous request to the Facebook server.
protected virtual Task<object> ApiTaskAsync(HttpMethod httpMethod, string path, object parameters, Type resultType, object userState, CancellationToken cancellationToken)
Parameters
httpMethod
HttpMethodHttp method. (GET/POST/DELETE)
path
stringThe resource path or the resource url.
parameters
objectThe parameters
resultType
TypeThe type of deserialize object into.
userState
objectThe user state.
cancellationToken
CancellationTokenThe cancellation token.
Returns
ApiTaskAsync(HttpMethod, string, object, Type, object, CancellationToken, IProgress<FacebookUploadProgressChangedEventArgs>)
protected virtual Task<object> ApiTaskAsync(HttpMethod httpMethod, string path, object parameters, Type resultType, object userState, CancellationToken cancellationToken, IProgress<FacebookUploadProgressChangedEventArgs> uploadProgress)
Parameters
httpMethod
HttpMethodpath
stringparameters
objectresultType
TypeuserState
objectcancellationToken
CancellationTokenuploadProgress
IProgress<FacebookUploadProgressChangedEventArgs>
Returns
Batch(params FacebookBatchParameter[])
Makes a batch request to the Facebook server.
public virtual object Batch(params FacebookBatchParameter[] batchParameters)
Parameters
batchParameters
FacebookBatchParameter[]List of batch parameters.
Returns
- object
The json result.
Batch(FacebookBatchParameter[], object)
Makes a batch request to the Facebook server.
public virtual object Batch(FacebookBatchParameter[] batchParameters, object parameters)
Parameters
batchParameters
FacebookBatchParameter[]List of batch parameters.
parameters
objectThe parameters
Returns
- object
The json result.
BatchTaskAsync(params FacebookBatchParameter[])
Makes an asynchronous batch request to the Facebook server.
public virtual Task<object> BatchTaskAsync(params FacebookBatchParameter[] batchParameters)
Parameters
batchParameters
FacebookBatchParameter[]List of batch parameters.
Returns
BatchTaskAsync(FacebookBatchParameter[], object, object, CancellationToken)
public virtual Task<object> BatchTaskAsync(FacebookBatchParameter[] batchParameters, object userToken, object parameters, CancellationToken cancellationToken)
Parameters
batchParameters
FacebookBatchParameter[]userToken
objectparameters
objectcancellationToken
CancellationToken
Returns
BatchTaskAsync(FacebookBatchParameter[], object, object, CancellationToken, IProgress<FacebookUploadProgressChangedEventArgs>)
Makes an asynchronous batch request to the Facebook server.
public virtual Task<object> BatchTaskAsync(FacebookBatchParameter[] batchParameters, object userState, object parameters, CancellationToken cancellationToken, IProgress<FacebookUploadProgressChangedEventArgs> uploadProgress)
Parameters
batchParameters
FacebookBatchParameter[]List of batch parameters.
userState
objectThe user state.
parameters
objectThe parameters.
cancellationToken
CancellationTokenThe cancellation token.
uploadProgress
IProgress<FacebookUploadProgressChangedEventArgs>
Returns
BatchTaskAsync(FacebookBatchParameter[], object, CancellationToken)
public virtual Task<object> BatchTaskAsync(FacebookBatchParameter[] batchParameters, object userToken, CancellationToken cancellationToken)
Parameters
batchParameters
FacebookBatchParameter[]userToken
objectcancellationToken
CancellationToken
Returns
BatchTaskAsync(FacebookBatchParameter[], object, CancellationToken, IProgress<FacebookUploadProgressChangedEventArgs>)
Makes an asynchronous batch request to the Facebook server.
public virtual Task<object> BatchTaskAsync(FacebookBatchParameter[] batchParameters, object userState, CancellationToken cancellationToken, IProgress<FacebookUploadProgressChangedEventArgs> uploadProgress)
Parameters
batchParameters
FacebookBatchParameter[]List of batch parameters.
userState
objectThe user state.
cancellationToken
CancellationTokenThe cancellation token.
uploadProgress
IProgress<FacebookUploadProgressChangedEventArgs>
Returns
CancelAsync()
Cancels asynchronous requests.
public virtual void CancelAsync()
Remarks
Does not cancel requests created using XTaskAsync methods.
Delete(string)
Makes a DELETE request to the Facebook server.
public virtual object Delete(string path)
Parameters
path
stringThe resource path or the resource url.
Returns
- object
The json result.
Delete(string, object)
Makes a DELETE request to the Facebook server.
public virtual object Delete(string path, object parameters)
Parameters
Returns
- object
The json result.
DeleteTaskAsync(string)
Makes an asynchronous DELETE request to the Facebook server.
public virtual Task<object> DeleteTaskAsync(string path)
Parameters
path
stringThe resource path or the resource url.
Returns
DeleteTaskAsync(string, object, CancellationToken)
Makes an asynchronous DELETE request to the Facebook server.
public virtual Task<object> DeleteTaskAsync(string path, object parameters, CancellationToken cancellationToken)
Parameters
path
stringThe resource path or the resource url.
parameters
objectThe parameters
cancellationToken
CancellationTokenThe cancellation token.
Returns
Get(object)
Makes a GET request to the Facebook server.
public virtual object Get(object parameters)
Parameters
parameters
objectThe parameters.
Returns
- object
The json result.
Get(string)
Makes a GET request to the Facebook server.
public virtual object Get(string path)
Parameters
path
stringThe resource path or the resource url.
Returns
- object
The json result.
Get(string, object)
Makes a GET request to the Facebook server.
public virtual object Get(string path, object parameters)
Parameters
Returns
- object
The json result.
Get(string, object, Type)
Makes a GET request to the Facebook server.
public virtual object Get(string path, object parameters, Type resultType)
Parameters
path
stringThe resource path or the resource url.
parameters
objectThe parameters.
resultType
TypeThe result type.
Returns
- object
The json result.
GetDialogUrl(string, object)
Gets the Facebook dialog url.
public virtual Uri GetDialogUrl(string dialog, object parameters)
Parameters
dialog
stringThe dialog name. Values can be oauth, feed, pagetab, friends, pay, apprequests, and send.
parameters
objectThe parameters.
Returns
- Uri
The dialog url.
Exceptions
- ArgumentNullException
If dialog or parameters is null.
GetLoginUrl(object)
Gets the Facebook OAuth login url.
public virtual Uri GetLoginUrl(object parameters)
Parameters
parameters
objectThe parameters.
Returns
- Uri
The login url.
Exceptions
- ArgumentNullException
If parameters is null.
GetLogoutUrl(object)
Gets the Facebook OAuth logout url.
public virtual Uri GetLogoutUrl(object parameters)
Parameters
parameters
objectThe parameters.
Returns
- Uri
The logout url.
GetTaskAsync(object)
Makes an asynchronous GET request to the Facebook server.
public virtual Task<object> GetTaskAsync(object parameters)
Parameters
parameters
objectThe parameters
Returns
GetTaskAsync(string)
Makes an asynchronous GET request to the Facebook server.
public virtual Task<object> GetTaskAsync(string path)
Parameters
path
stringThe resource path or the resource url.
Returns
GetTaskAsync(string, object)
Makes an asynchronous GET request to the Facebook server.
public virtual Task<object> GetTaskAsync(string path, object parameters)
Parameters
Returns
GetTaskAsync(string, object, CancellationToken)
Makes an asynchronous GET request to the Facebook server.
public virtual Task<object> GetTaskAsync(string path, object parameters, CancellationToken cancellationToken)
Parameters
path
stringThe resource path or the resource url.
parameters
objectThe parameters
cancellationToken
CancellationTokenThe cancellation token.
Returns
GetTaskAsync(string, object, CancellationToken, Type)
Makes an asynchronous GET request to the Facebook server.
public virtual Task<object> GetTaskAsync(string path, object parameters, CancellationToken cancellationToken, Type resultType)
Parameters
path
stringThe resource path or the resource url.
parameters
objectThe parameters
cancellationToken
CancellationTokenThe cancellation token.
resultType
TypeThe result type.
Returns
GetTaskAsync<TResult>(object)
Makes an asynchronous GET request to the Facebook server.
public virtual Task<TResult> GetTaskAsync<TResult>(object parameters)
Parameters
parameters
objectThe parameters
Returns
- Task<TResult>
The json result task.
Type Parameters
TResult
The result type.
GetTaskAsync<TResult>(string)
Makes an asynchronous GET request to the Facebook server.
public virtual Task<TResult> GetTaskAsync<TResult>(string path)
Parameters
path
stringThe resource path or the resource url.
Returns
- Task<TResult>
The json result task.
Type Parameters
TResult
The result type.
GetTaskAsync<TResult>(string, object)
Makes an asynchronous GET request to the Facebook server.
public virtual Task<TResult> GetTaskAsync<TResult>(string path, object parameters)
Parameters
Returns
- Task<TResult>
The json result task.
Type Parameters
TResult
The result type.
GetTaskAsync<TResult>(string, object, CancellationToken)
Makes an asynchronous GET request to the Facebook server.
public virtual Task<TResult> GetTaskAsync<TResult>(string path, object parameters, CancellationToken cancellationToken)
Parameters
path
stringThe resource path or the resource url.
parameters
objectThe parameters
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task<TResult>
The json result task.
Type Parameters
TResult
The result type.
Get<TResult>(object)
Makes a GET request to the Facebook server.
public virtual TResult Get<TResult>(object parameters)
Parameters
parameters
objectThe parameters.
Returns
- TResult
The json result.
Type Parameters
TResult
The result type.
Get<TResult>(string)
Makes a GET request to the Facebook server.
public virtual TResult Get<TResult>(string path)
Parameters
path
stringThe resource path or the resource url.
Returns
- TResult
The json result.
Type Parameters
TResult
The result type.
Get<TResult>(string, object)
Makes a GET request to the Facebook server.
public virtual TResult Get<TResult>(string path, object parameters)
Parameters
Returns
- TResult
The json result.
Type Parameters
TResult
The result type.
OnDeleteCompleted(FacebookApiEventArgs)
Raise OnDeletedCompleted event handler.
[Obsolete]
protected virtual void OnDeleteCompleted(FacebookApiEventArgs args)
Parameters
args
FacebookApiEventArgsThe FacebookApiEventArgs.
OnGetCompleted(FacebookApiEventArgs)
Raise OnGetCompleted event handler.
[Obsolete]
protected virtual void OnGetCompleted(FacebookApiEventArgs args)
Parameters
args
FacebookApiEventArgsThe FacebookApiEventArgs.
OnPostCompleted(FacebookApiEventArgs)
Raise OnPostCompleted event handler.
[Obsolete]
protected virtual void OnPostCompleted(FacebookApiEventArgs args)
Parameters
args
FacebookApiEventArgsThe FacebookApiEventArgs.
OnUploadProgressChanged(FacebookUploadProgressChangedEventArgs)
Raise OnUploadProgressCompleted event handler.
[Obsolete]
protected void OnUploadProgressChanged(FacebookUploadProgressChangedEventArgs args)
Parameters
ParseDialogCallbackUrl(Uri)
Parses the dialog callback url to an object of the resulting data.
public virtual object ParseDialogCallbackUrl(Uri uri)
Parameters
uri
Uri
Returns
Exceptions
ParseOAuthCallbackUrl(Uri)
Parse the url to FacebookOAuthResult.
public virtual FacebookOAuthResult ParseOAuthCallbackUrl(Uri uri)
Parameters
uri
Uri
Returns
Exceptions
ParseSignedRequest(string)
Parse the facebook signed_request.
public virtual object ParseSignedRequest(string signedRequestValue)
Parameters
signedRequestValue
stringThe signed_request value.
Returns
- object
The parse signed_request value.
Exceptions
- ArgumentNullException
Throws if appSecret or signedRequestValue is null or empty.
- InvalidOperationException
If the signedRequestValue is an invalid signed_request.
ParseSignedRequest(string, string)
Parse the facebook signed_request.
public virtual object ParseSignedRequest(string appSecret, string signedRequestValue)
Parameters
Returns
- object
The parse signed_request value.
Exceptions
- ArgumentNullException
Throws if appSecret or signedRequestValue is null or empty.
- InvalidOperationException
If the signedRequestValue is an invalid signed_request.
Post(object)
Makes a POST request to the Facebook server.
public virtual object Post(object parameters)
Parameters
parameters
objectThe parameters.
Returns
- object
The json result.
Post(string, object)
Makes a POST request to the Facebook server.
public virtual object Post(string path, object parameters)
Parameters
Returns
- object
The json result.
PostTaskAsync(object)
Makes an asynchronous POST request to the Facebook server.
public virtual Task<object> PostTaskAsync(object parameters)
Parameters
parameters
objectThe parameters
Returns
PostTaskAsync(string, object)
Makes an asynchronous POST request to the Facebook server.
public virtual Task<object> PostTaskAsync(string path, object parameters)
Parameters
Returns
PostTaskAsync(string, object, object, CancellationToken)
Makes an asynchronous POST request to the Facebook server.
public virtual Task<object> PostTaskAsync(string path, object parameters, object userState, CancellationToken cancellationToken)
Parameters
path
stringThe resource path or the resource url.
parameters
objectThe parameters
userState
objectThe user state.
cancellationToken
CancellationTokenThe cancellation token.
Returns
PostTaskAsync(string, object, object, CancellationToken, IProgress<FacebookUploadProgressChangedEventArgs>)
public virtual Task<object> PostTaskAsync(string path, object parameters, object userState, CancellationToken cancellationToken, IProgress<FacebookUploadProgressChangedEventArgs> uploadProgress)
Parameters
path
stringparameters
objectuserState
objectcancellationToken
CancellationTokenuploadProgress
IProgress<FacebookUploadProgressChangedEventArgs>
Returns
PostTaskAsync(string, object, CancellationToken)
Makes an asynchronous POST request to the Facebook server.
public virtual Task<object> PostTaskAsync(string path, object parameters, CancellationToken cancellationToken)
Parameters
path
stringThe resource path or the resource url.
parameters
objectThe parameters
cancellationToken
CancellationTokenThe cancellation token.
Returns
SetDefaultHttpWebRequestFactory(Func<Uri, HttpWebRequestWrapper>)
Sets the default http web request factory.
public static void SetDefaultHttpWebRequestFactory(Func<Uri, HttpWebRequestWrapper> httpWebRequestFactory)
Parameters
httpWebRequestFactory
Func<Uri, HttpWebRequestWrapper>
SetDefaultJsonSerializers(Func<object, string>, Func<string, Type, object>)
Sets the default json seriazliers and deserializers.
public static void SetDefaultJsonSerializers(Func<object, string> jsonSerializer, Func<string, Type, object> jsonDeserializer)
Parameters
jsonSerializer
Func<object, string>Json serializer
jsonDeserializer
Func<string, Type, object>Json deserializer
SetHttpWebRequestFactory(Func<Uri, HttpWebRequestWrapper>)
Sets the http web request factory for the current instance of FacebookClient.
public virtual void SetHttpWebRequestFactory(Func<Uri, HttpWebRequestWrapper> httpWebRequestFactory)
Parameters
httpWebRequestFactory
Func<Uri, HttpWebRequestWrapper>
SetJsonSerializers(Func<object, string>, Func<string, Type, object>)
Sets the json seriazliers and deserializers for the current instance of FacebookClient.
public virtual void SetJsonSerializers(Func<object, string> jsonSerializer, Func<string, Type, object> jsonDeserializer)
Parameters
jsonSerializer
Func<object, string>Json serializer
jsonDeserializer
Func<string, Type, object>Json deserializer
TryParseOAuthCallbackUrl(Uri, out FacebookOAuthResult)
Try parsing the url to FacebookOAuthResult.
public virtual bool TryParseOAuthCallbackUrl(Uri url, out FacebookOAuthResult facebookOAuthResult)
Parameters
url
UriThe url to parse
facebookOAuthResult
FacebookOAuthResultThe facebook oauth result.
Returns
- bool
True if parse successful, otherwise false.
TryParseSignedRequest(string, out object)
Tries parsing the facebook signed_request.
public virtual bool TryParseSignedRequest(string signedRequestValue, out object signedRequest)
Parameters
Returns
- bool
True if signed request parsed successfully otherwise false.
TryParseSignedRequest(string, string, out object)
Tries parsing the facebook signed_request.
public virtual bool TryParseSignedRequest(string appSecret, string signedRequestValue, out object signedRequest)
Parameters
appSecret
stringThe app secret.
signedRequestValue
stringThe signed_request value.
signedRequest
objectThe parsed signed request.
Returns
- bool
True if signed request parsed successfully otherwise false.
VerifyGetSubscription(string, string, string)
Verify HTTP_X_HUB_SIGNATURE for HTTP GET.
public virtual void VerifyGetSubscription(string requestHubMode, string requestVerifyToken, string requestHubChallenge)
Parameters
requestHubMode
stringThe request hub.mode
requestVerifyToken
stringThe request hub.verify_token
requestHubChallenge
stringThe request hub.challenge
VerifyGetSubscription(string, string, string, string)
Verify HTTP_X_HUB_SIGNATURE for HTTP GET.
public virtual void VerifyGetSubscription(string requestHubMode, string requestVerifyToken, string requestHubChallenge, string verifyToken)
Parameters
requestHubMode
stringThe request hub.mode
requestVerifyToken
stringThe request hub.verify_token
requestHubChallenge
stringThe request hub.challenge
verifyToken
stringExpected verify token.
VerifyPostSubscription(string, string)
Verify HTTP_X_HUB_SIGNATURE for HTTP POST.
public object VerifyPostSubscription(string requestHttpXHubSignature, string requestBody)
Parameters
requestHttpXHubSignature
stringThe request HTTP_X_HUB_SIGNATURE
requestBody
stringThe request body.
Returns
VerifyPostSubscription(string, string, string)
Verify HTTP_X_HUB_SIGNATURE for HTTP POST.
public virtual object VerifyPostSubscription(string requestHttpXHubSignature, string requestBody, string appSecret)
Parameters
requestHttpXHubSignature
stringThe request HTTP_X_HUB_SIGNATURE
requestBody
stringThe request body.
appSecret
stringThe App secret.
Returns
VerifyPostSubscription(string, string, Type)
Verify HTTP_X_HUB_SIGNATURE for HTTP POST.
public object VerifyPostSubscription(string requestHttpXHubSignature, string requestBody, Type resultType)
Parameters
requestHttpXHubSignature
stringThe request HTTP_X_HUB_SIGNATURE
requestBody
stringThe request body.
resultType
TypeThe result type.
Returns
VerifyPostSubscription(string, string, Type, string)
Verify HTTP_X_HUB_SIGNATURE for HTTP POST.
public virtual object VerifyPostSubscription(string requestHttpXHubSignature, string requestBody, Type resultType, string appSecret)
Parameters
requestHttpXHubSignature
stringThe request HTTP_X_HUB_SIGNATURE
requestBody
stringThe request body.
resultType
TypeThe result type.
appSecret
stringThe App secret.
Returns
Events
DeleteCompleted
Event handler for delete completion.
public event EventHandler<FacebookApiEventArgs> DeleteCompleted
Event Type
GetCompleted
Event handler for get completion.
public event EventHandler<FacebookApiEventArgs> GetCompleted
Event Type
PostCompleted
Event handler for post completion.
public event EventHandler<FacebookApiEventArgs> PostCompleted
Event Type
UploadProgressChanged
Event handler for upload progress changed.
public event EventHandler<FacebookUploadProgressChangedEventArgs> UploadProgressChanged