Sharing for Devices

With Sharing for Devices, people can easily share content from devices to Facebook. This includes Smart TVs, digital photo frames, or Internet of Things devices.

With device sharing, your device shows an alphanumeric code and tells people to enter it on a web page on their desktop PC or smartphone. People using your app or service can then share content to Facebook with a share dialog associated with the code.

If you're building an app for Apple TV or Android devices, you should use our SDK for tvOS or SDK for Android respectively.

This guide describes the following:

User Experience

1. Call-to-Action

First consider where in your user experience you want to ask people to share content to Facebook. To ensure the best experience, design the button to look as much as possible like the official Facebook Share button. In general, the button should be next to the content to be shared.

From a visual design perspective, this means that you should

  1. Label the button with "Share" or “Share to Facebook”.
  2. Use white and the official Facebook brand blue: #3B5998.
  3. If your device supports a graphical display, you can also incorporate the official “f” logo. According to the Facebook brand guidelines, the logo should always be either white or Facebook blue (#3B5998).

2. Display the Code

When someone clicks the call-to-action, your device makes a call to Facebook's API which returns a code.

In your interface, tell people that they need to visit a website and enter the code with the following message, “Next, visit facebook.com/device (http://facebook.com/device) on your desktop or smartphone and enter this code”. Display the full code you received from Facebook's Device Share API. The code is between 6 and 12 characters long.

Include a Close or Done button so people can finish the Device Sharing flow.

3. Sharing

This is the flow people see when they go to facebook.com/device on their desktop or mobile browser. First they see a text field where they can enter their code:

After they enter their code and click Continue, they will be presented a Share Dialog:

So people know their share is successful, they then see a confirmation message:

Implement Sharing for Devices

Facebook Sharing for Devices is for devices that can make HTTP calls over the internet. The following are the API calls and responses your device can make.

1. Enable Login for Devices

Load your app's dashboard and change Settings > Advanced > OAuth Settings > Login from Devices to 'Yes'.

2. Generate a Code

When the person clicks the Share call-to-action, you device should make an HTTP POST to:

POST https://graph.facebook.com/device/share
       access_token=<APPID|CLIENT_TOKEN>
       href=<LINK_TO_SHARE>

The CLIENT_TOKEN is found in your App Settings -> Advanced, and should be combined with your app ID (separated with a pipe, |) to form the complete access_token.

The API also supports action_type and action_properties instead of href if you want to share an Open Graph story (in the same manner as Open Graph actions in Share Dialog).

The API also supports quote and hashtag parameters (in the same manner as the Share Dialog parameters).

The response is in this form:

{
  "user_code": "A1NWZ9",
  "verification_uri": "https://www.facebook.com/device",
  "expires_in": 420,
}

This response means:

  1. Display the string “A1NWZ9” on your device.
  2. Tell the person to go to “facebook.com/device” and enter this code.
  3. The code expires in 420 seconds. You should close the code display after that time.

3. Display the Code

Your device should display the user_code and tell people to visit the verification_uri such as facebook.com/device on their PC or smartphone. See User Experience.

Troubleshooting

Can I make device flow requests over HTTP?
Graph API with tokens requires TLS/HTTPS.

Can I make device flow requests with the GET method?
All device flow requests should be POST requests.

Can I tell when the person has completed a share?
No.

Can I post on the person's behalf programmatically?
No. To do that, you must ask the user to log in and grant permissions for you to publish on their behalf. See publishing with the Graph API to learn more.