1

我想在 Facebook 页面的时间线上发布照片,而不是使用 PHP SDK 的用户

这是我正在使用的示例代码

            <?php
            include_once("config.php");

            if($_POST)
            {   
                if(strlen($_POST["message"])<1) 
                {
                    //message is empty
                    $userMessage = 'No message!';
                }
                //Post variables we received from user
                $userPageIds    = '00000000000000';

                $facebook->setFileUploadSupport(true);

                    $userMessage    = $_POST["message"];
                    //HTTP POST request to PAGE_ID/feed with the publish_stream
                    $post_url = '/'.$userPageId.'/albums';

                    //*
                    // posts message on page feed
                    $page_info = $facebook->api("/$userPageId?fields=access_token");

                $access_token = $facebook->getAccessToken();



                 // Get the new album ID
                 $albums = $facebook->api($userPageId.'/albums','GET',array('access_token'=>$access_token));      
             foreach($albums['data'] as $album)
             {
                echo $album['name'];
               if($album['name'] == 'Timeline Photos')
               {
                 $album_id = $album['id'];
               }
             }


                    $args = array(
                       'message' => $userMessage,
                       'image' => '@' . $_FILES['img']['tmp_name'],
                       'aid' => $album_id,
                       'no_story' => 0,
                       'access_token' => $page_info['access_token']
                      );

                if ($fbuser) {
                  try {
                        $postResult = $facebook->api('/'.$album_id.'/photos', 'post', $args);
                    } catch (FacebookApiException $e) {
                    echo $e->getMessage();
                  }
                }else{
                 $loginUrl = $facebook->getLoginUrl(array('redirect_uri'=>$homeurl,'scope'=>$fbPermissions));
                 header('Location: ' . $loginUrl);
                }

                //Show sucess message


            }

            ?>

此代码将照片添加到页面的时间线相册,但它没有出现在页面的墙上

任何帮助是极大的赞赏。

4

0 回答 0