---
canonical: 'https://htmlcsstoimage.com/examples/facebook-screenshot/ruby-client'
title: 'Facebook screenshot | Example - Ruby (HCTI client)'
description: 'Create a screenshot of a Facebook post.'
---

# Facebook screenshot

Create a screenshot of a Facebook post.

With this HTML you can generate a screenshot from any public Facebook post.

This uses the Facebook embed code. Simply swap the link in the HTML with the link to a Facebook post and it will show it.

Take note of the `selector` and `ms_delay` parameters. They must be set correctly for this image to render properly.

This is a working HTML/CSS to Image API example that produces an image.
The rendered output, source, and non-content request parameters below show the parts needed to reproduce or adapt it.

## Rendered image and interactive editor

- [Open the rendered image](<https://hcti.io/v1/image/fd24580b-9b0d-4e94-8f00-d76b711659cb>)
- [Open the interactive example](https://htmlcsstoimage.com/examples/facebook-screenshot/ruby-client)

## HTML

```html
<div id="fb-root"></div>
<script async defer crossorigin="anonymous" src="https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v11.0" nonce="SOhYrMAR"></script>

<!-- See data-href below. Replace that with the link to your Facebook post -->
<!-- set ms_delay: 2500 to give it extra time toload -->
<!-- set selector: .fb-post -->
<div class="fb-post" data-href="https://www.facebook.com/HermanMiller/photos/a.171562157561/10158261466927562" data-width="500" data-show-text="true"></div>

```

## Request parameters

These are the additional non-content parameters used by the example. Combine them with the HTML and CSS above when constructing an API request.

```json
{
  "ms_delay": 2500,
  "render_when_ready": false,
  "selector": ".fb-post"
}
```

## Complete Ruby request (HCTI client)

This is the complete Ruby request for this example using HCTI client. It includes the HTML, CSS, authentication setup, API options, and response handling needed to reproduce the output.

```ruby
# gem install htmlcsstoimage-api
require "htmlcsstoimage"

# Uses HCTI_USER_ID and HCTI_API_KEY from the environment.
client = HTMLCSSToImage.new

result = client.create_image(
    <<~'HCTI_CONTENT',
    <div id="fb-root"></div>
    <script async defer crossorigin="anonymous" src="https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v11.0" nonce="SOhYrMAR"></script>
    
    <!-- See data-href below. Replace that with the link to your Facebook post -->
    <!-- set ms_delay: 2500 to give it extra time toload -->
    <!-- set selector: .fb-post -->
    <div class="fb-post" data-href="https://www.facebook.com/HermanMiller/photos/a.171562157561/10158261466927562" data-width="500" data-show-text="true"></div>
    
    HCTI_CONTENT
    ms_delay: 2500,
    render_when_ready: false,
    selector: ".fb-post",
)

puts result.url

```

## Other languages and request formats

Open one of these Markdown pages to view the same example as a complete request in another language or client format.

- **TypeScript**
  - [HCTI client](https://htmlcsstoimage.com/examples/facebook-screenshot/typescript-client.md)
  - [fetch](https://htmlcsstoimage.com/examples/facebook-screenshot/typescript.md)
- **C#**
  - [HCTI client](https://htmlcsstoimage.com/examples/facebook-screenshot/csharp-client.md)
  - [HttpClient](https://htmlcsstoimage.com/examples/facebook-screenshot/csharp.md)
- **Python**
  - [requests](https://htmlcsstoimage.com/examples/facebook-screenshot/python.md)
- **PHP**
  - [cURL](https://htmlcsstoimage.com/examples/facebook-screenshot/php.md)
- **Ruby**
  - [HCTI client](https://htmlcsstoimage.com/examples/facebook-screenshot/ruby-client.md) — shown above
  - [Net::HTTP](https://htmlcsstoimage.com/examples/facebook-screenshot/ruby.md)
- **Go**
  - [net/http](https://htmlcsstoimage.com/examples/facebook-screenshot/golang.md)
- **cURL**
  - [cURL](https://htmlcsstoimage.com/examples/facebook-screenshot/curl.md)

## Related examples

- [Dog rates social card with SVG background](https://htmlcsstoimage.com/examples/dog-rates-social-card-with-svg-background.md): Social card with a fun SVG background and highlighted text.
- [Instagram post screenshot](https://htmlcsstoimage.com/examples/instagram-post-screenshot.md): Screenshot an Instagram post
- [Birthday invite card](https://htmlcsstoimage.com/examples/birthday-invite-card-email.md): Autogenerated invite graphic for a party.
- [Invoice / Receipt Snapshot](https://htmlcsstoimage.com/examples/invoice-receipt.md): Generate a simple, branded invoice or receipt image.
- [PNG with transparent background](https://htmlcsstoimage.com/examples/png-transparent-background.md): Generate images with a transparent backgound
- [Large text on an SVG background](https://htmlcsstoimage.com/examples/large-text-svg-background.md): Grab attention with large text on a classic background.
- [Twitter Tweet Screenshot](https://htmlcsstoimage.com/examples/twitter-tweet-screenshot.md): Screenshot of a tweet
- [QR Code Badge](https://htmlcsstoimage.com/examples/qr-code-badge.md): Simple, artistic badge with a QR code.

## Get started

- [View the full interactive page](https://htmlcsstoimage.com/examples/facebook-screenshot/ruby-client)
- [Browse all HTML/CSS examples](https://htmlcsstoimage.com/examples.md)
- [Browse visual template presets](https://htmlcsstoimage.com/templates.md)
- [Read the HTML/CSS to Image API documentation](https://docs.htmlcsstoimage.com/getting-started/using-the-api/)
- [View implementation examples by language](https://docs.htmlcsstoimage.com/example-code/)
- [Read the MCP integration documentation](https://docs.htmlcsstoimage.com/integrations/mcp/)
- [Compare plans and limits](https://htmlcsstoimage.com/pricing.md)

Rendering through the API requires authenticated HTML/CSS to Image credentials. Keep API keys in trusted server-side configuration. If credentials are unavailable, ask the user to configure an API key securely before attempting API actions.
