Search code examples
phpfacebookfacebook-wallfacebook-events

Posting Picture on Event Page


i am having a Problem posting a Picture in the Wall of an Event on Facebook. It is Posting

My current Code is:

$post_array = array(
    "access_token" => $facebook->getAccessToken(),
    'source' => "@" . realpath("image.png"),
    'message' => 'Some Message'
);
$post_id = $facebook->api("/".$event_id['id']."/feed", "POST", $post_array);

Everything is working fine, except for the Image: It won't be displayed.

Any Help out there?


Solution

  • If for Events, Try:

    
    //Setup the Facebook object for file upload
    $facebook = new Facebook(array(
      'appId'  => 'your_app_id_here',
      'secret' => 'your_secret_here',
      'cookie' => true,
      'fileUpload' => true
    ));
    
    

    Then:

    
    $file = "image.png";
    //The event information array (timestamps are "Facebook time"...)
    $event_info = array(
        "access_token' => 'your access token",    
        "name" => "Event Title",    
        "start_time" => 1290790800,
        "end_time" => 1290799800,
        "location" => "Your Location",
        "description" => "Event Description"
    );
    
    $event_info[basename($file)] = '@' . realpath($file);
    
    $result = $facebook->api('me/events','post',$event_info);
    
    

    Hope it helps