0

Can anyone shed some light on my problem?

<?php

$config = array();
$config['appId'] =  "foo";
$config['secret'] = "bar";
$config['cookie'] = true;
$config['fileUpload'] = true;

$facebook = new Facebook($config);

$eventParams = array(
    "privacy_type"  => $this->request->data['Event']['privacy'],
    "name"          => $this->request->data['Event']['event'],
    "description"   => $this->request->data['Event']['details'],
    "start_time"    => $this->request->data['Event']['when'],
    "country"       => "NZ"
);

//around 300x300 pixels
//I have set the permissions to Everyone
$imgpath = "C:\\Yes\\Windows\\Path\\Photo_for_the_event_app.jpg"; 
$eventParams["@file.jpg"] = "@".$imgpath;

$fbEvent = $facebook->api("me/events", "POST", $eventParams);

var_dump($fbEvent); //I get the event id

I also have this in my "scope" when the user is asked to Allow the app to post on his behalf: user_about_me,email,publish_stream,create_event,photo_upload

This works. It creates the event with all the details I have specified. EXCEPT for the event image.

I have been to most of Stackoverflow posts related to my problem but all of them are not working for me. (EG: https://stackoverflow.com/a/4245260/66767)

I also do not get any error.

Any ideas?

THanks!

Community
  • 1
  • 1
wenbert
  • 5,263
  • 8
  • 48
  • 77

1 Answers1

0

Yes, the idea is that Facebook has bug. I have problems with event picture as well. The topic in tracker and this is my post on stackOverflow

Btw, you can try this code after creating the event ->

public function uploadFacebookEventPicture($fullPath, $eventId) {
    $mainImage = '@' . $fullPath;   
    $imgData = array(
        'picture' => $mainImage
    );
    try {
        $data = $this->facebook->api('/'.$eventId, 'post', $imgData);
        return $data;
    } catch (FacebookApiException $e) {
        error_log('Failed to attach picture to event. Exception: ' . $e->getMessage());
    }       
    return null;
} 

Maybe it will work for you, for me it stopped to work since Facebook issue was discovered.

Community
  • 1
  • 1
divide by zero
  • 2,340
  • 5
  • 23
  • 34
  • I have tried to upload the photo after Creating the event but still no success. I have also tried to use `//picture` with `source` as the key for the param. Did not work. Another thing: When I disable the "Event Timezones" in the App settings, I get a "Try later" error. – wenbert Aug 30 '12 at 03:19
  • this script was working 2 weeks ago, and key param really doesn't make any sense, i tried different ones and the upload was successful... something wrong with FB. At least investigation of this problem don't give result how to fix it from our side. – divide by zero Aug 30 '12 at 05:09
  • I think the problem maybe the "Event Timezone". My plan is to disable the "Event Timezone" in the App admin setting and then add a `timezone` to the event params. At the moment, if I disable the "Event Timezone" setting, I get this error: `You must enter a valid date and time` – wenbert Sep 02 '12 at 21:57