用于Facebook的PHP SDK:上传使用Graph API创建的事件的图像


PHP SDK for Facebook: Uploading an Image for an Event created using the Graph API

有人能解释一下我的问题吗?

<?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

这是有效的。它使用我指定的所有细节创建事件。事件图像除外。

我去过大多数与我的问题相关的Stackoverflow帖子,但所有这些都不适合我。(例如:https://stackoverflow.com/a/4245260/66767)

我也没有得到任何错误。

有什么想法吗?

THanks!

是的,这个想法是Facebook有bug。我对活动图片也有问题。跟踪器中的主题,这是我在stackOverflow 上的帖子

顺便说一句,你可以在创建事件后尝试这个代码->

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问题被发现后,它就停止了工作。