English 中文(简体)
脸书相册创建工作不顺利
原标题:Face book album creation is not working well

Iam 试图上传图像到facebook 相册。 现在图像被上传到有facebook 应用程序名称的相册上。 我想上传图像到名为 Flowers 的相册上 。

我使用以下代码。

<?php
    require_once  fbpic/library/facebook.php ;

    $app_id = "xxxx";
    $app_secret = "xxxxx";
    $facebook = new Facebook(array(
      appId  => $app_id,
      secret  => $app_secret,
      cookie  => true
    ));
    $fbcheck= $facebook->getUser();

    if(is_null($fbcheck) or !$fbcheck or $fbcheck==0)
    {
     header("Location:{$facebook->getLoginUrl(array( scope  =>  user_status,publish_stream,user_photos,photo_upload ))}");

    }



        $facebook->setFileUploadSupport("http://" . $_SERVER[ SERVER_NAME ]);
        // add a status message
        $photo = $facebook->api( /me/photos ,  POST , 
            array(
                 source  =>  @  .realpath("ContactUs.jpg") ,
                 message  =>  It is a programming test 
            )
        );

? & gt;

问题回答

Facebook博客文章中的情景2应该有帮助:https://developers.facebook.com/blog/post/498/

检查相册退出与否 。

Do a get on graphurl/{userId}/albums . ( You can also use FQL to do the same task)

插入列表以查看是否已经有名的相册退出 。

If already exits Post the Pic with the url graphurl/{albumId}/photos

If album does not exits create the album. Do a post on $facebookGraphUrl. /me/albums with params name and description.

使用相册 ID 将相册张贴在此相册上 。

祝你好运

参考"http:// developmenters.facebook.com/docs/reference/api/album/#photos" rel="nofollow" > this

您可以通过向 ALBUM_ID/photos 发布 HTTP POST 请求, 将照片添加到相册中, 并发布_ 流权限及以下参数 。

    Parameter   Description         Type                    Required 
    source      Photo content       multipart/form-data     yes
    message     Photo description   string                  no 

所以 而不是

 $photo = $facebook->api( /me/photos ,  POST , 
            array(
                 source  =>  @  .realpath("ContactUs.jpg") ,
                 message  =>  It is a programming test 
            )
        );

你应该这样做,

 $photo = $facebook->api( /<your_album_id>/photos ,  POST , 
            array(
                 source  =>  @  .realpath("ContactUs.jpg") ,
                 message  =>  It is a programming test 
            )
        );

p.s.s. 如果您不指定相册_id, facebook 为您创建专辑, 包括应用程序名称, 如果应用程序名称已经创建, 则所有没有相册_ id 的照片都转到该专辑





相关问题
Using QCView and iSight to capture image

I have a QCView that loads a Quartz file which gives you iSights feedback (basically like a QTCaptureView) Everything displays fine The button simply takes a snapshot using the following simple ...

Taking picture with QTCaptureView

Is it possible to simply take a picture and save it somewhere using a QTCaptureView and Apple s built-in iSight? I ve seen lots of tutorials on recording video but none on simply taking a picture. Any ...

Transform rectangular image into trapezoid

In .NET how can I transform an image into a trapezoid. The Matrix class supports rotation, shear, etc, but I can t see a trapezoidal transformation. I m using the usual System.Drawing.* API, but I m ...

Rotate image through Y-axis on web page

What are my options for rotating an image on a web page through the Y-axis? I m not sure if I even have the terminology right. Is this called a rotate or a transform. Most of the searches that I ve ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

Editing a xaml icons or images

Is it possible to edit a xaml icons or images in the expression design or using other tools? Is it possible to import a xaml images (that e.g you have exported) in the expression designer for editing?...

Convert from 32-BPP to 8-BPP Indexed (C#)

I need to take a full color JPG Image and remap it s colors to a Indexed palette. The palette will consist of specific colors populated from a database. I need to map each color of the image to it s "...

热门标签