PHP SDK for Facebook: Uploading an Image for an Event created using the Graph API
Posted
by
wenbert
on Stack Overflow
See other posts from Stack Overflow
or by wenbert
Published on 2012-08-29T03:34:29Z
Indexed on
2012/08/29
3:38 UTC
Read the original article
Hit count: 193
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: http://stackoverflow.com/a/4245260/66767)
I also do not get any error.
Any ideas?
THanks!
© Stack Overflow or respective owner