Graph API Version

Canvas Button

Reading

A button inside the canvas

Examples

Graph API Explorer
GET /v2.10/{canvas-button-id} HTTP/1.1
Host: graph.facebook.com
/* PHP SDK v5.0.0 */
/* make the API call */
$request = new FacebookRequest(
  $session,
  'GET',
  '/{canvas-button-id}'
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
/* handle the result */
/* make the API call */
FB.api(
    "/{canvas-button-id}",
    function (response) {
      if (response && !response.error) {
        /* handle the result */
      }
    }
);
/* make the API call */
new GraphRequest(
    AccessToken.getCurrentAccessToken(),
    "/{canvas-button-id}",
    null,
    HttpMethod.GET,
    new GraphRequest.Callback() {
        public void onCompleted(GraphResponse response) {
            /* handle the result */
        }
    }
).executeAsync();
// For more complex open graph stories, use `FBSDKShareAPI`
// with `FBSDKShareOpenGraphContent`
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                               initWithGraphPath:@"/{canvas-button-id}"
                                      parameters:params
                                      HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    // Handle the result
}];
If you want to learn how to use the Graph API, read our Using Graph API guide.

Parameters

This endpoint doesn't have any parameters.

Fields

FieldDescription

action

CanvasOpenURLAction

The action associated with the button

background_color

string

Color of the button background

bottom_padding

numeric string

The padding below the element

button_color

string

Color of the button

button_style

enum

The style of the button

deep_link

string

Deep link destination only for mobile apps (used for mobile install or engagement ads, and app link is supported)

element_type

enum

The type of the element

id

numeric string

The id of the element

element_group_key

string

The element group key to bundle multiple elements in editing

font_family

string

The font family

font_size

numeric string

The size of the font for the text

line_height

numeric string

The line height of the text

name

string

The name of the element

rich_text

The text inside the button

text_alignment

enum

The alignment of the text

text_color

string

The color of the text

top_padding

numeric string

The padding above the element

Edges

No edges

Validation Rules

ErrorDescription
100Invalid parameter

Creating

You can't perform this operation on this endpoint.

Updating

You can update a CanvasButton by making a POST request to /{canvas_button_id}.

Parameters

NameDescription
background_color
string

Background color of the button

bottom_padding
float

The padding below the button

button_color
string

The color of the button

button_style
enum {BUTTON_OUTLINE, BUTTON_FILLED}

The style of the button

font_family
string

The font family of the text on the button

font_size
int64

The size of the font for the text on the button

line_height
float

The line height of the text on the button

name
string

Name of the button

open_url_action
Object

the destination url after user clicks the button, by setting this, the canvas button will have action with OPEN URL type

rich_text
Object

The text inside the button

text_alignment
enum {LEFT, CENTER, RIGHT}

The alignment of the text on the button

text_color
string

The color of the text on the button

top_padding
float

The padding above the button

Return Type

This endpoint supports read-after-write and will read the node to which you POSTed.
Struct {
success: bool,
}

Validation Rules

ErrorDescription
100Invalid parameter
200Permissions error
210User not visible

Deleting

You can delete a CanvasButton by making a DELETE request to /{canvas_button_id}.

Parameters

This endpoint doesn't have any parameters.

Return Type

Struct {
success: bool,
}

Validation Rules

ErrorDescription
100Invalid parameter