Graph API Version

Canvas Text

Reading

Text element of the canvas

Permissions

Developers usually request these permissions for this endpoint:

Marketing Apps
  • ads_management
  • manage_pages
  • pages_show_list
Page management Apps
No data
Other Apps
No data

Example

Graph API Explorer
GET /v2.11/{canvas-text-id} HTTP/1.1
Host: graph.facebook.com
/* PHP SDK v5.0.0 */
/* make the API call */
try {
  // Returns a `Facebook\FacebookResponse` object
  $response = $fb->get(
    '/{canvas-text-id}',
    '{access-token}'
  );
} catch(Facebook\Exceptions\FacebookResponseException $e) {
  echo 'Graph returned an error: ' . $e->getMessage();
  exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
  exit;
}
$graphNode = $response->getGraphNode();
/* handle the result */
/* make the API call */
FB.api(
    "/{canvas-text-id}",
    function (response) {
      if (response && !response.error) {
        /* handle the result */
      }
    }
);
/* make the API call */
new GraphRequest(
    AccessToken.getCurrentAccessToken(),
    "/{canvas-text-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-text-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

background_color

string

The color of the background for the element

id

numeric string

The id of the element

bottom_padding

numeric string

The padding below the element

element_group_key

string

The element group key to bundle multiple elements in editing

element_type

enum

The type of the element

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 content of the element

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

Example

You can update a CanvasText by making a POST request to /{canvas_text_id}.

Parameters

NameDescription
background_color
string

The color of the background for the text

bottom_padding
float

The padding below the text

font_family
string

The font family of the text

font_size
int64

The size of the font for the text

line_height
float

The line height of the text

name
string

Name of the text element

rich_text
Object

The text content of the text element

text_alignment
enum {LEFT, CENTER, RIGHT}

The alignment of the text

text_color
string

The color of the text

top_padding
float

The padding above the text

Return Type

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

Validation Rules

ErrorDescription
200Permissions error
210User not visible

Deleting

Example

You can delete a CanvasText by making a DELETE request to /{canvas_text_id}.

Parameters

This endpoint doesn't have any parameters.

Return Type

Struct {
success: bool,
}

Validation Rules

ErrorDescription
210User not visible