Search code examples
phpfacebookfbsdk

How to post a .swf on Facebook PHP SDK


I am trying to post a .swf using PHP SDK 5.2. I have tried a few methods.
For example:

$linkData = [
'type'=> "video",
'source'=> "https://mysite/my_file.swf",
'name'=> $_GET['message1'],
'caption'=> $_GET['caption'], 
'description'=> $_GET['message2'],
'message' => $_GET['message3']
];
try {
    $response = $fb->post('/me/feed', $linkData, $user->access_token);
  } catch(Facebook\Exceptions\FacebookResponseException $e) {
    $this->ueoutputs['errors'][] = $e->getMessage();
    exit;
  } catch(Facebook\Exceptions\FacebookSDKException $e) {
    $this->ueoutputs['errors'][] = $e->getMessage();
    exit;
  }

it gives me a Facebook\Exceptions\FacebookResponseException:

Template data must be a JSON-encoded dictionary, of the form {'key-1': 'value-1', 'key-2': 'value-2', ...}

How to solve this?


Solution

  • The solution to this is using the Open Graph Protocol. Here is an example:

    <meta property="og:audio" content="http://example.com/bond/theme.mp3" />
    <meta property="og:description" 
      content="Sean Connery found fame and fortune as the
               suave, sophisticated British agent, James Bond." />
    <meta property="og:determiner" content="the" />
    <meta property="og:locale" content="en_GB" />
    <meta property="og:locale:alternate" content="fr_FR" />
    <meta property="og:locale:alternate" content="es_ES" />
    <meta property="og:site_name" content="IMDb" />
    <meta property="og:video" content="http://example.com/bond/trailer.swf" />