Php 使用Facebook Graph API创建相册并上传照片

Php 使用Facebook Graph API创建相册并上传照片,php,facebook,codeigniter,facebook-graph-api,Php,Facebook,Codeigniter,Facebook Graph Api,我使用Facebook graph api从我的站点使用codeigniter上传Facebook中的照片。 但多次在facebook上上传相同的图片。 我的代码如下: # Path to facebook's PHP SDK. require_once(APPPATH."libraries/facebook.php"); # Facebook application config. // newcheck app [testpurpose ....] $config

我使用Facebook graph api从我的站点使用codeigniter上传Facebook中的照片。 但多次在facebook上上传相同的图片。 我的代码如下:

# Path to facebook's PHP SDK.       

require_once(APPPATH."libraries/facebook.php");

# Facebook application config.
    // newcheck app [testpurpose ....]

$config = array(
            'appId'      => 'APP ID',
            'secret'     => 'SECRET KEY',
            'fileUpload' => true # Optional and can be set later as well (Using setFileUploadSupport() method).
        );



# Create a new facebook object.
        $facebook = new Facebook($config);

        # Current user ID.
        $user_id = $this->facebook->getUser();

        # Check to see if we have user ID.
        if($user_id) {

            # If we have a user ID, it probably means we have a logged in user.
            # If not, we'll get an exception, which we handle below.
            try {

                # Get the current user access token:
                $access_token = $this->facebook->getAccessToken();

                # Upload photo to the album we've created above:
                $image_absolute_url = 'http://abc.com/research_social_sites/figures/pie.jpg';

                $photo_details = array();
                $photo_details['access_token']  = $access_token;
                $photo_details['url']           = $image_absolute_url;                        # Use this to upload image using an Absolute URL.
                $photo_details['message']       = 'Your picture message/caption goes here'. date('Y-m-d H:i:s') .'->BY RLS';

                $upload_photo = $this->facebook->api('/me/photos', 'POST', $photo_details);

                # Output photo ID:
                echo '<br>Photo ID: ' . $upload_photo['id'];
            } catch(FacebookApiException $e) {
                // If the user is logged out, you can have a 
                // user ID even though the access token is invalid.
                // In this case, we'll get an exception, so we'll
                // just ask the user to login again here.
                $login_url = $this->facebook->getLoginUrl( array('scope' => 'publish_stream, user_photos')); 
                echo 'Error Uploading Image <br> Please <a href="' . $login_url . '">login.</a>';
                }   
        } else {

            # No user, print a link for the user to login and give the required permissions to perform tasks.
            $params = array(
            'scope' => 'publish_stream, user_photos', # These permissions are required in order to upload image to user's profile.
            );

            $login_url = $this->facebook->getLoginUrl($params);
            echo 'You are not Logged in <br> Please <a href="' . $login_url . '">login.</a>';
        }
但它的工作原理很好,但主要问题是它上传的文件不止一次相同的图像。 因此,请帮助我给出停止在facebook上多次上传图像的解决方案。
谢谢您的合作。

多个?多少次?每次SDK在此代码中发现登录用户时,您都会上载一张照片,因此每当用户调用此脚本时,就会发生这种情况。如果你不想发生这种情况,请找到另一个触发器来上传照片–例如,让用户明确单击链接或按钮。将同一张照片上传2到3次Stéphane Bruckert@CBroe你能给我展示一下放跳跳虎的例子吗