How to upload custom app image (tab_image) for Timeline Page tabs via API?

我与影子孤独终老i 提交于 2019-12-05 12:45:47

Updated 2016:

With the latest Open Graph 2.5 API tabs endpoint and PHP SDK 5, the code should look like this:

<?php 
$fb = new Facebook\Facebook([/* . . . */]);
$response = $fb->post(
    '/{page-id}/tabs',
    [
        'custom_name'=>'My Custom Tab',
        'custom_image_url'=>'http://publicly.accessible/image.jpg',
        'app_id'=>'{app-id}',
    ],
    '{page-access-token}',
);

Original 2012 post:

I figured it out, it's just like uploading an image. The field is called "custom_image". Presumably they will update the documentation soon. It's nice they enabled this API hook so quickly with the new release!

Here's how to do it with the Facebook PHP SDK:

<?php
$page_access_token = 'XXXXXXX'; // you'll need the manage_pages permission to get this
$facebook = new Facebook(array(
  'appId'  => 'YOUR_APP_ID',
  'secret' => 'YOUR_APP_SECRET',
  'fileUpload' => true, // enables CURL @ file uploads
));
$facebook->api(
  '/PAGE_ID/tabs/TAB_NAME', // looks like "app_xxxx" where xxxx = APP_ID
  'POST' // post to update
  array(
    'custom_image' => '@' . realpath('path/to/my/file.jpg'),
    'custom_name' => 'My App', // give it a custom name if you want too
    'access_token' => $page_access_token // access token for the page
  )
);

Cheers

As you said Timeline for Pages is just announced and it's too soon to say it'll be possible via API. Currently it's not possible even in settings of your App in Developer Application.

This information is simply not yet documented in help center or Graph API documentation.

It's also way soon to say someone have discovered if such functionality exists...

We all should wait a bit and probably file bugs which may get some response from officials confirming, rejecting or adding this to wish list.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!