0

With the same access token as the one I used to create a page event, I tried to upload a photo to it with the PHP SDK 3.1.1

The checklist:

  • I am passing an access token
  • The access token I'm passing does have create_event, publish_stream, photo_upload
  • I am making a call to /EVENT_ID/picture
  • I am using the method POST
  • The params do contain the needed access token and source=@ABSOLUTE_PATH_TO_IMAGE
  • File upload support is turned on for the PHP SDK object

What I have tried previously (mostly seperately)

  • Trying to upload a picture within the same params of the request for creating the event, with the source param, using @ before the full image file path
  • The same, but instead of using the param "source", I tried $params[basename($file)] = '@' . $file;
  • Trying to add a picture to /EVENT_ID/picture, but with url = URL_TO_FILE instead of source = @ABSOLUTE_PATH_TO_FILE (results in the exact same error, "An unknown error has occured"
  • Adding a message param with text to the params where I upload the picture separately from creating the event
  • Adding venue=null to the params for where I create the event
  • I have tried using the latest Facebook SDK PHP files

Here is a PHP var_dump() of the two requests:

array(6) {
  ["name"]=>
  string(11) "Superman IV"
  ["start_time"]=>
  string(24) "2012-09-23T16:00:00+0200"
  ["end_time"]=>
  string(24) "2012-09-23T17:30:00+0200"
  ["description"]=>
  string(237) "Lex Luther wykrada z muzeum włosy Supermana. Dzięki nim udaje mu się stworzyć super robota, Nuclear Mana, który potrafi czerpać energię ze słońca. Dzięki temu Nuclear Man staje się niezniszczalny i staje do walki z Supermanem."
  ["access_token"]=>
  string(118) "<censored>"
  ["@event_cover.jpg"]=>
  string(61) "@/var/www/rr048_attila/templates/template/img/event_cover.jpg"
}
array(2) {
  ["access_token"]=>
  string(118) "<censored>"
  ["source"]=>
  string(61) "@/var/www/rr048_attila/templates/template/img/event_cover.jpg"
}

Note that for the @event_cover.jpg param, I tried doing the same without the @ in the key, and also without that param at all.

Here is a var_dump() of the error I get for the second request:

array(2) {
  ["error_code"]=>
  int(1)
  ["error_msg"]=>
  string(25) "An unknown error occurred"
}

Does anyone have any idea what is causing this problem, or what I forgot to do?

Attila Szeremi
  • 5,235
  • 5
  • 40
  • 64

1 Answers1

2

At the moment, this can be affected by Facebook bug. I am tracking it here Also I've created similar question, from my point of view, but no one answered it. (question can be found here) The issue can be connected to Timezone Migration, because before that my events and picture upload to them worked properly and no changes to script were made.

Community
  • 1
  • 1
divide by zero
  • 2,340
  • 5
  • 23
  • 34
  • In the facebook ticket you wrote, you say you get the same (#1) "Unknown error occured" error, but in the stackoverflow one, you say you got (#324) Missing or invalid image file. Those kind of seem different. Are they both caused by the timezone migration? Also, I'm giving my dates in the format Facebook wants it, including the timezone. Isn't that supposed to let me not get the bug? – Attila Szeremi Sep 03 '12 at 13:08
  • I was trying in different ways and also hard-coded link that should upload pic, but that was unsuccessful. – divide by zero Sep 03 '12 at 13:11
  • Ah you're right. I disabled "Events Timezone" in the App Advanced settings, and the result: using the second request still doesn't work and gives the same error, but both using `$param[basename($file)] = $file;` or `$param['@' . basename($file)] = $file;` So great. To everyone who reads this stackoverflow solution: this is a temporary solution, because this is still a bug. If it gets fixed and this hack isn't recommended anymore, please remind me with a commend, and I'll amend my question with a warning. – Attila Szeremi Sep 03 '12 at 13:17