Skip to main content

Detailed User Flow

Detailed User Flow

Below is a step-by-step example on how to effectively use the BusinessLinksAPI with PHP and Laravel. You may use any language or framework at your discretion. This comprehensive flow ensures simplicity and ease of use.

  1. Register tenant API: To create a new API, please request admin to set it up for you. Provide your email and specify the desired subscription plans. By default, two plans, "free" and "premium" will be generated.
  2. Obtain Access Token: In order to access the API, you will need to include a bearer token in the header or pass the access_token as a parameter. Here's an example using PHP with Laravel:
    <?php
    // Laravel example
    use Illuminate\Support\Facades\Http;
    ...
    $tokenRequest = Http::post('https://blt.brownbook.net/access-token',[
    'email' => 'api@brownbook.net', 'password' =>'some_password']);
    if ($tokenRequest->status() == 200) {
    $response = $tokenRequest->json();
    $accessToken = $response['data']['token'];
    }
    Response
    {
    "message": "Access token has been generated",
    "data": {
    "token": "YOUR_TOKEN"
    },
    "success": true
    }
  3. Create a Business Page for a User and assign Subscription Plan: Users possess the capability to create a business page and connect it to a designated user, along with the option to assign an associated subscription plan. The available Subscription plans include "free" and "premium". This selection ensures that the business page is linked to the preferred plan, providing access to the desired subscription features and benefits. The following PHP code demonstrates this process:
    $businessPageRequest = Http::withHeaders(['Authorization' => 'Bearer ' . $accessToken])
    ->post('https://blt.brownbook.net/api/tenant/pages', [
    "name" => "Brownbook.net",
    "address" => "80 East Street, Brighton",
    "country" => "UK",
    "phone" => "16463245332",
    "email" => "admin@brownbook.net",
    "description" => "Brownbook.net is the free Global Business Listing Database that anyone can edit.",
    "linkedin" => "https://www.linkedin.com/company/brownbooknet/",
    "user" => [
    "full_name" => "Jane Doe",
    "username" => "jane.doe",
    "email" => "jane_doe@gmail.com",
    "country_code" => "US",
    "avatar" => "https://i.pravatar.cc/300",
    "mobile_phone" => "16465553890"
    ],
    "media" => [
    "url_path" => "https://upload.wikimedia.org/wikipedia/en/f/fc/World_of_Warcraft_The_Burning_Crusade.png"
    ],
    "subscription" => "premium"
    ]);
    if ($businessPageRequest->status() === 200) {
    $response = $businessPageRequest->json();
    $businessPage = $response['data'];
    }
    Response
    {
    "message": "Business page has been created successfully",
    "data": {
    "id": 1,
    "name": "Brownbook.net",
    "address": "80 East Street, Brighton",
    "country": "UK",
    "phone": "16463245332",
    "email": "adminas@brownbook.net",
    "username": "brownbooknet",
    "description": "Brownbook.net is the free Global Business Listing Database that anyone can edit.",
    "user": {
    "id": 1,
    "full_name": "Jane Doe",
    "email": "jane_doe_test1@gmail.com",
    "created_at": "2024-03-21T17:41:44.000000Z",
    "country_code": "US",
    "avatar": "https:\/\/i.pravatar.cc\/300",
    "mobile_phone": "16465553890",
    "access_token": "eyJpdiI6InhGR2VTY3VvQ2UwalV2Q2ZML0RjMVE9PSIsInZhbHVlIjoiR2xmbnhWTFVJVjhKb2JWY2dFdGlXa2dtWmwreDlzVTRZbHpLT3kxd3h2VE50SVNTVWI0MTFmVmZyQjkyNHpPZGNuNkhlZk1rbmI0OXBOVDJGSmFpOEhiOTN4K2FveFRIbUZpcWpNaXNrMzJBZmxwaWoyZHZ1UUI4MThHTGJ5MXQiLCJtYWMiOiIyMDZmNTdmZGVhNmU4YzU2MTA0NjBlZmQzNTMzMGM3NzBiOGJkNDU5Yjk2YTMyZDY1NTllMDg4M2Y3NzQ0YTk3IiwidGFnIjoiIn0="
    },
    "meta": [],
    "media": {
    "id": 1,
    "file_name": null,
    "full_path": "",
    "url_path": "https:\/\/warlordsofdraenor.com\/uploads\/logo.png",
    "type": "image",
    "mediable_type": "App\\Domains\\Page\\Models\\BusinessPage",
    "mediable_id": 3,
    "created_at": "2024-03-21T17:42:03.000000Z",
    "updated_at": "2024-03-21T17:42:03.000000Z"
    },
    "subscription": "premium"
    },
    "success": true
    }

Notes

You can now follow the newly created business page by following this link:

https://{YourTenantId}.blinx.biz/brownbooknet.

Your TenantId will be provided upon successful registration. You'll receive this information via email once your request has been processed by admin@brownbook.net. brownbooknet is a username of created business page that can be taken from API response when business page created.

To manage a business page from the user side, you can use the following URL:

https://{YourTenantId}.blinx.biz/admin/login?access_token={token}&action=edit&page_id={id}

In our case, we can obtain the {id} from data.id = 1 and the access token from data.user.access_token. The URL will look like this:

https://{YourTenantId}.blinx.biz/admin/login?access_token=eyJpdiI6InhGR2VTY3VvQ2UwalV2Q2ZML0RjMVE9PSIsInZhbHVlIjoiR2xmbnhWTFVJVjhKb2JWY2dFdGlXa2dtWmwreDlzVTRZbHpLT3kxd3h2VE50SVNTVWI0MTFmVmZyQjkyNHpPZGNuNkhlZk1rbmI0OXBOVDJGSmFpOEhiOTN4K2FveFRIbUZpcWpNaXNrMzJBZmxwaWoyZHZ1UUI4MThHTGJ5MXQiLCJtYWMiOiIyMDZmNTdmZGVhNmU4YzU2MTA0NjBlZmQzNTMzMGM3NzBiOGJkNDU5Yjk2YTMyZDY1NTllMDg4M2Y3NzQ0YTk3IiwidGFnIjoiIn0&action=edit&page_id=1

Regenerate User Token

To regenerate a new user access token, tenants can use the following request:

   curl --request POST \
--url https://blt.brownbook.net/api/tenant/users/token \
--header 'Authorization: Bearer eyJpdiI6IjBPOUxKbEYrWjNOSXpONDZiMzIzOEE9PSIsInZhbHVlIjoibjlhN05adTZvK09JRzNQOW8xL2ptU2ZEajdwaEppbTQxek9GbU1TL0ZjSVoxdDBzZis2VTF5TWFUbmJWVWFsZnF2clRIOFVneTI0M1crYTFUVklrMTUvNWV5ZmlMa1FSSzluOTN0WEJQTUk9IiwibWFjIjoiZTA3MzNhN2EwOGJjZmUyODBlNTIzNmU5NjlhMDZiZTc0OGRmYmM2Nzk3ZWU4NjQ2MDVmZWVjMmEyYzU2NTFhMiIsInRhZyI6IiJ9' \
--header 'Content-Type: multipart/form-data' \
--header 'User-Agent: insomnia/2023.5.8' \
--form email=jane_doe@gmail.com

Response will be in a json format:

   {
"message": "User access token retrieved successfully",
"data": {
"token": "eyJpdiI6ImtPaWxQVVBNMkx6V1Z2eXRZL0xUTUE9PSIsInZhbHVlIjoidzNwSlFQVktmbGhMQmFadHd0azA3aE9QdWtGbTRyQW10R0cxSUltNHpyVzhGZGIrSFZZQnM3WWp5bnJjSFZFWW4xOGVtZytyU2dkU2FxRWtVWUtkUng0YktoK1pvbVg5eFhoUmdaT3M5K2M9IiwibWFjIjoiZTMzZWI5ZTk0YmYwMDJlMjdmMDFiODcyYzg3NmFkMTU0NjNlNTlhZDJmYzMwZTJiMzQ4NTMxODczNjhmYzIzZSIsInRhZyI6IiJ9",
"expires_at": "2024-03-25 13:40:07"
},
"success": true
}

Use the new token to access the Blinx page editor for the user.

When creating a business page, there are three parameters that need explanation: route_redirect_data, route_subscribe_data, and route_unsubscribe_data.

These parameters are JSON fields that can contain any data, formatted as "key": "value". When a tenant registers, they specify three links:

A link for returning to their website (preferably redirecting to the user's business page). A link for payment subscription (which needs to be specified). A link for unsubscribing (canceling the subscription).

The tenant should specify these three links in the following format. For example, the return back link could be:

https://website.com/my-business/{businessId}/

In this case, {businessId} is a dynamic parameter. When the tenant creates a business page, the parameter route_redirect_data should be specified like this:

route_redirect_data: {businessId:134324}

When the page is retrieved on our frontend side, the redirection route will be changed to:

https://website.com/my-business/134324/

The other two routes for subscription and unsubscribing can be specified similarly. For example, if the tenant specifies the payment URL as:

https://pay.website.com/{businessId}/{userId}/{secureToken}/

The parameter route_subscribe_data should have the following parameters:

route_subscribe_data: {"businessId":142, "userId":5, "secureToken":"some token"}

On the frontend, the URL will be replaced with these parameters, becoming:

https://pay.website.com/142/5/some_token/

The third parameter follows the same principle, requiring correct keys and templates to be provided.

Unsubscribe user

To unsubscribe a user, follow these steps:

  1. Obtain the Access Token as explained above;
  2. Search for the User by Email or Username:
    $usersRequest = Http::withHeaders(['Authorization' => 'Bearer ' . $accessToken])
    ->get('https://blt.brownbook.net/api/tenant/users', [
    'email' => '.net'
    ]);
    if ($usersRequest->status() === 200) {
    $response = $usersRequest->json();
    $users = $response['data']['data'];
    }
    Response
       {
    "message": "User has been retrieved successfully",
    "data": {
    "current_page": 1,
    "data": [
    {
    "id": 1,
    "full_name": "Cary Hill",
    "username": "yvette30",
    "email": "jayson.rogahn@kertzmann.net",
    "created_at": "2023-07-18T15:22:34.000000Z",
    "country_code": "FI",
    "avatar": "",
    "mobile_phone": "820-826-2018",
    "business_pages": [
    {
    "name": "Jaunita Skiles",
    "address": "80 Henry Taylor Street, Flint,CH6 5PS",
    "country": "HU",
    "phone": "+1 (458) 757-9631",
    "email": "eryn36@pouros.com",
    "description": "Facere et possimus sit qui quo. Dolor architecto error molestiae aut consequatur in. Velit ut saepe eaque ut.",
    "meta": [],
    "media": [],
    "subscription": "premium"
    }
    ]
    },
    {
    "id": 48,
    "full_name": "Ms. Lorna Kris",
    "username": "botsford.cornell",
    "email": "adrianna.lynch@walsh.net",
    "created_at": "2023-07-18T15:22:49.000000Z",
    "country_code": "BA",
    "avatar": "",
    "mobile_phone": "+1.425.278.5050",
    "business_pages": [
    {
    "name": "Dr. Irwin Runte",
    "address": "141 Roby Road, Bowring Park,L14 3NU",
    "country": "PN",
    "phone": "(856) 756-7420",
    "email": "beth.mueller@yahoo.com",
    "description": "Non aspernatur veniam molestias explicabo. Aliquid sequi in accusamus ratione unde ut nisi. Libero officiis soluta aut ex sed nihil amet repellendus.",
    "meta": [],
    "media": [],
    "subscription": "free"
    }
    ]
    }
    ],
    "first_page_url": "https:\/\/blt.brownbook.net\/api\/tenant\/users?page=1",
    "from": 1,
    "last_page": 1,
    "last_page_url": "https:\/\/blt.brownbook.net\/api\/tenant\/users?page=1",
    "links": [
    {
    "url": null,
    "label": "&laquo; Previous",
    "active": false
    },
    {
    "url": "https:\/\/blt.brownbook.net\/api\/tenant\/users?page=1",
    "label": "1",
    "active": true
    },
    {
    "url": null,
    "label": "Next &raquo;",
    "active": false
    }
    ],
    "next_page_url": null,
    "path": "https:\/\/blt.brownbook.net\/api\/tenant\/users",
    "per_page": 10,
    "prev_page_url": null,
    "to": 2,
    "total": 2
    },
    "success": true
    }
  3. After a successful search, identify the User's ID and make an API call to unsubscribe the user. For example, with id = 48:
       $userUnsubscribeRequest = Http::withHeaders(['Authorization' => 'Bearer ' . $accessToken])
    ->delete('https://blt.brownbook.net/api/tenant/users/48');
    if ($userUnsubscribeRequest->status() === 200) {
    $response = $userUnsubscribeRequest->json();
    $message = $response['message'];
    }
    Response
    {
    "message": "User has been deleted successfully",
    "success": true
    }

Restore user

Deleted users can be recreated with new subscriptions or restored by requesting assistance from admin