dongshao4207 2012-03-06 19:09
浏览 19
已采纳

在非对象上调用成员函数setFileUploadSupport()

I am developing my first facebook app, which includes creating a new album and posting photos to the user wall.

By learning through facebook documentation and few tutorial and came up this code, but I am getting following error with it.

Fatal error: Call to a member function setFileUploadSupport() on a non-object …

        $facebook -> setFileUploadSupport(true);
        $album_details = array('message' => 'Album desc', 'name' => 'Album name');
        $create_album = $facebook -> api('/me/albums', 'post', $album_details);
        $album_uid = $create_album['id'];

        $photo_details = array('message' => 'Photo message');
        $file = 'app.jpg';
        $photo_details['image'] = '@' . realpath($file);

        $upload_photo = $facebook -> api('/' . $album_uid . '/photos', 'post', $photo_details);

Kindly help me with this. thankyou

  • 写回答

3条回答 默认 最新

  • dongsisui7562 2012-03-13 20:49
    关注

    You will need instantiate the class with file upload support and request the correct permissions.

    $facebook = new Facebook(array(
        'appId'  => 'YOUR_APP_ID',
        'secret' => 'YOUR_APP_SECRET',
        'fileUpload' => true // enable file upload support
    ));
    
    // get a login url with the correct perms
    $facebook->getLoginUrl(array(
      'scope' => 'photo_upload,first_name,email,publish_stream,read_stream'
    ));
    

    photo_upload is the key permission here, allowing you to upload photos.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 MATLAB中streamslice问题
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 51单片机中C语言怎么做到下面类似的功能的函数(相关搜索:c语言)
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序