面向Facebook的PHP SDK:上传使用Graph API创建的事件的图片 [英] PHP SDK for Facebook: Uploading an Image for an Event created using the Graph API
问题描述
任何人都可以了解我的问题吗?
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
当用户被询问时,我也在我的范围允许应用程式代表他发布: user_about_me,email,publish_stream,create_event,photo_upload
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.
我一直到大多数Stackoverflow与我的问题相关的帖子,但他们都不为我工作。 (EG: http://stackoverflow.com/a/4245260/66767 )
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.
任何想法?
谢谢!
推荐答案
错误。
我也有事件图片的问题。 跟踪器中的主题,这是我的 post on stackOverflow
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,您可以尝试此代码创建事件后 - >
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;
}
也许它会为你工作,因为我从Facebook问题停止工作被发现。
Maybe it will work for you, for me it stopped to work since Facebook issue was discovered.
这篇关于面向Facebook的PHP SDK:上传使用Graph API创建的事件的图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!