Facebook Login

In order for these endpoints to work correctly, Facebook Login must be enabled in Sparkart Tools. Under Settings > Authentication Options, make sure the Facebook App ID and Facebook App Secret fields are filled in and enabled.

These resources are for the following Facebook actions:

These endpoints require Facebook's signedRequest parameter that is returned from using Facebook's Javascript SDK

POST /login

Customers can login with Facebook Login. Customers must have previously connected their Facebook accounts in order to login with it.

This endpoint is identical to basic email/password login with the exception of the request parameters.

Request

Name Type Description
facebook_signed_request string [Required] The signedRequest parameter returned after successfully logging into Facebook
{
  "facebook_signed_request": "seTFbtEMkr4gyh9BgbhdP7bRm1sdDldHit2N1vuZINo.eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImNvZGUiOiJBUUNSSE1RWXhHTE5QQTFYXzhBLVgzVmlvcXNmaE9XZUxkUmkxYjZiM1RLb0R4UE11THVic29Wc2hRX1M5OXRwam1YMzV1aHZkNExLV1h4WWNDZjRaZzJGcmV6ZHV4dVZUdjU2VnhxWjZlY3B2Qkt0eGQ3NmhmNWRaMW8yaDNVa3RmeHVfbEJEb0RpNHV5dW9SOHh1QmdBM1ZMc2diVmoydC1xTEFkWDY1U3J0V19TVURUX20xNDNJLXVoT2ktNGo3OFVOVFVxMl9UUEpXQU90b2p3OU1EaTIiLCJpc3N1ZWRfYXQiOjEzNjAwMzI4NzUsInVzZXJfaWQiOiIxMDAwMDAyNjg1MjI0MjMifQ"
}

Responses

Success: Signed request successfully verified

{
    "status": "ok",
    "customer": {
        "id": 2,
        "first_name": "Test",
        "last_name": "Robot",
        "email": "test@example.com",
        "birthdate": "1995-01-30",
        "fanclub_id": 1,
        "expired": false,
        "authentications": [{
            "name": "facebook"
        }]
        "subscription": {
            "plan": {
                "id": 1,
                "name": "The Free Plan",
                "description": null,
                "annotations": null
            },
            "start_date": "2013-01-30T03:56:34Z",
            "affiliates": []
        }
    }
}

Failure: Signed request could not be verified

{
    "status": "error",
    "messages": [
        "Invalid request: Too old. Please try logging into Facebook again."
    ]
}

Failure: Facebook account not linked to a customer

{
    "status": "error",
    "messages": [
        "Sorry, your Facebook account does not have access to this website."
    ]
}

Failure: Facebook Login has not been enabled

Defaults to email/password login. Please refer to basic login documentation

{
    "status": "error",
    "messages": [
        "Email and password combination is incorrect."
    ]
}

POST /account/register

Customer account registration allows the customer to connect a Facebook account, accept the terms of service, and supply other account information. A customer can only register if their customer_id is saved in the session.

For purchasing a free plan, a customer can only register if an order associated with a free plan in the session.

This endpoint is identical to basic registration with the exception of the request parameter.

Request

Name Type Description
facebook_signed_request string [Required] The signedRequest parameter returned after successfully logging into Facebook
email string [Required] Customer's email
Only required after purchasing a free plan
first_name string [Optional] Customer's first name
last_name string [Optional] Customer's last name
birthdate string [Required] Customer's date of birth
Only required after purchasing a free plan
Format: YYYY-MM-DD
username string [Required] Customer's username
Only required if fanclub supports Vanilla Forums
accept_terms boolean [Required] Whether or not the customer has accepted the Terms of Service

Registering an account for a new customer purchasing a free plan:

{
    "facebook_signed_request": "seTFbtEMkr4gyh9BgbhdP7bRm1sdDldHit2N1vuZINo.eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImNvZGUiOiJBUUNSSE1RWXhHTE5QQTFYXzhBLVgzVmlvcXNmaE9XZUxkUmkxYjZiM1RLb0R4UE11THVic29Wc2hRX1M5OXRwam1YMzV1aHZkNExLV1h4WWNDZjRaZzJGcmV6ZHV4dVZUdjU2VnhxWjZlY3B2Qkt0eGQ3NmhmNWRaMW8yaDNVa3RmeHVfbEJEb0RpNHV5dW9SOHh1QmdBM1ZMc2diVmoydC1xTEFkWDY1U3J0V19TVURUX20xNDNJLXVoT2ktNGo3OFVOVFVxMl9UUEpXQU90b2p3OU1EaTIiLCJpc3N1ZWRfYXQiOjEzNjAwMzI4NzUsInVzZXJfaWQiOiIxMDAwMDAyNjg1MjI0MjMifQ",
    "email": 'test@example.com',
    "first_name": 'Test',
    "last_name": 'Robot',
    "birthdate": "1991-02-23",
    "username": "jackson5"
    "accept_terms": true,
}

Responses

Success: Registered an account for a new customer purchasing a free plan

{
    "status": "ok",
    "customer": {
        "id": 2,
        "first_name": "Test",
        "last_name": "Robot",
        "email": "test@example.com",
        "birthdate": "1995-01-30",
        "fanclub_id": 1,
        "expired": false,
        "authentications": [{
            "name": "facebook"
        }]
        "subscription": {
            "plan": {
                "id": 1,
                "name": "The Free Plan",
                "description": null,
                "annotations": null
            },
            "start_date": "2013-01-30T03:56:34Z",
            "affiliates": []
        }
    }
}

Failure: Trying to register with valid facebook_signed_request but without any other parameters

{
    "status": "error",
    "messages": [
        "Email can't be blank",
        "Birthdate can't be blank",
        "Password can't be blank",
        "Must accept terms of service"
    ]
}

Failure: Trying to register with invalid facebook_signed_request

{
    "status": "error",
    "messages": [
        "Invalid request: Invalid signature. Please try logging into Facebook again."
    ]
}

POST /account/connect/facebook

Signed in customers who have not connected a Facebook account can associate an account through this endpoint. This endpoint will not allow customers to associate a different Facebook account if they already have one.

Request

Name Type Description
facebook_signed_request string [Required] The signedRequest parameter returned after successfully logging into Facebook
{
  "facebook_signed_request": "seTFbtEMkr4gyh9BgbhdP7bRm1sdDldHit2N1vuZINo.eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImNvZGUiOiJBUUNSSE1RWXhHTE5QQTFYXzhBLVgzVmlvcXNmaE9XZUxkUmkxYjZiM1RLb0R4UE11THVic29Wc2hRX1M5OXRwam1YMzV1aHZkNExLV1h4WWNDZjRaZzJGcmV6ZHV4dVZUdjU2VnhxWjZlY3B2Qkt0eGQ3NmhmNWRaMW8yaDNVa3RmeHVfbEJEb0RpNHV5dW9SOHh1QmdBM1ZMc2diVmoydC1xTEFkWDY1U3J0V19TVURUX20xNDNJLXVoT2ktNGo3OFVOVFVxMl9UUEpXQU90b2p3OU1EaTIiLCJpc3N1ZWRfYXQiOjEzNjAwMzI4NzUsInVzZXJfaWQiOiIxMDAwMDAyNjg1MjI0MjMifQ"
}

Responses

Success: Signed request successfully verified

{
    "status": "ok",
    "messages": [
        "Your Facebook account has been connected"
    ]
}

Failure: Signed request could not be verified

{
    "status": "error",
    "messages": [
        "Invalid request: Format. Please try logging into Facebook again."
    ]
}

Failure: Facebook Login not enabled

{
    "status": "error",
    "messages": [
        "Facebook login is not supported by this website"
    ]
}

Failure: Customer already has an associated Facebook account

{
    "status": "error",
    "messages": [
        "Authentications provider has already been taken"
    ]
}

Failure: Customer not logged in

{
    "status": "error",
    "messages": [
        "Must be logged in"
    ]
}

POST /account/connect/deauthorize_facebook

This endpoint is the Deauthorize Callback URL used by Facebook to ping the app when a customer de-authorizes the fanclub's Facebook application. This endpoint will unlink that customer's Facebook uid from their customer record.

To use, just paste the following URL into the Facebook field found in your app's advanced settings page:

http://services.sparkart.net/api/v1/account/connect/deauthorize_facebook?key=YOUR_APP_API_KEY