Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/257.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Open Graph用户变量在授权后变为null_Php_Facebook_Facebook Opengraph - Fatal编程技术网

Php Open Graph用户变量在授权后变为null

Php Open Graph用户变量在授权后变为null,php,facebook,facebook-opengraph,Php,Facebook,Facebook Opengraph,我正在使用Facebook的Open Graph API从用户帐户导入用户的图像 但当我点击登录按钮并打开URL时,经过授权后,它会再次要求我登录 这是我的index.php: <?php ini_set("display_errors",0); if ( !defined('ABSPATH') ) require_once '../../../../wp-load.php'; include_once __DIR__."/fbmain.php";

我正在使用Facebook的Open Graph API从用户帐户导入用户的图像

但当我点击登录按钮并打开URL时,经过授权后,它会再次要求我登录

这是我的
index.php

<?php

    ini_set("display_errors",0);
    if ( !defined('ABSPATH') )
        require_once '../../../../wp-load.php';
    include_once __DIR__."/fbmain.php";
    include_once __DIR__."/facebook.php";

    if(!session_id())session_start();
    global $fbSiteUrl;
    /*$base_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']!='off') ? 'https://' : 'http://';
    $base_url .= $_SERVER['HTTP_HOST'];*/
    $fbSiteUrl = COO_PLUGIN_URL."/create-own-object/plugin-facebook";//$base_url.substr(__DIR__,strpos(__DIR__,'/phase2-newer'));

/*if(isset($_GET['logout']) && $_GET['logout']=='yes'){
    $user = null;
    $facebook->logoutFromSite();
}*/

if (!$user){
?>
    <div class="facebook_login_box" id='fbLoginBtn'>
        <div class="text-center">
            <a href="#"><img src="<?php echo $fbSiteUrl; ?>/Images/facebook_logo.png" alt="" ></a>
        </div>
        <div class="fb_login">
            <button type="button" class="fb_login_btn" style="margin-right: 90px;" onclick="authoriseToSocialMedia('<?php echo $loginUrl; ?>');">Login</button>
        </div>
    </div>
<?php
}// else { ?>
    <!--    <div class="right_side">
        <a href="<? //= $logoutUrl; ?>" onClick='loader()'><img src="Images/logout.png"></a>
    </div> -->
<?php //} ?>
<img src="<?php echo $fbSiteUrl; ?>/Images/folder_fb.png" style="display:none;">
<!-- all time check if user session is valid or not -->
<?php
if ($user) {
?>
    <div id ='FBcontent'>
        <form id ='FBcontentFrm' method="post" action="index.php">          
            <div class="folderset" id="folderList">
                <!-- Data retrived from user profile are shown here -->
                <?php
                    $albums = $facebook->api("/me/albums");
                    foreach($albums['data'] as $album){
                    ?>
                        <div class="box">
                            <a href="javascript:void(0);" onclick="showAlbum('<?php echo $album['id']; ?>')">
                                <img src="<?php echo $fbSiteUrl; ?>/Images/folder_fb.png">
                                <div style="clear: both;"></div><?php echo $album['name']; ?>
                            </a>
                    </div>
                    <?php
                    }
                ?>
                <div class="clearfix"></div>
            </div>

            <div id="fbhtmlImage">
                <!-- Album images are being loaded here. -->
            </div>
        </form>

        <script>
            if((this.window.focus() || !(this.window.closed)) && window.opener != null)
            {
                window.opener.document.getElementById('facebook_content').innerHTML = document.getElementById('FBcontent').innerHTML;
                window.opener.document.getElementById("fbLoginBtn").style.visibility="hidden";
                this.window.close();
            }
        </script>
    </div>  
<?php } ?>
<script type="text/javascript">
    function backToAlbums(){
        $('#fbhtmlImage').hide();
        $('#fbmodal-footer').hide();
        $('#folderList').show();
    }
    function showAlbum(albumId){
        $('#loader_img').show();

        <?php global $fbSiteUrl;?>
        $('#folderList').hide();
        var fbhtml = '';
        fbhtml += '<div class="image_list addimage_box_col">\
            <div class="row">\
                <div class="col-lg-2 col-sm-3 col-xs-6">\
                    <a class="pink_btn" href="javascript: void(0);" onClick="backToAlbums();">Back</a>\
                </div>\
            </div>\
            <div class="clearfix"></div>\
        </div>';

        $.ajax({
            type: "GET",
            url: "<?php echo $fbSiteUrl; ?>/fbphotos.php",
            data: { albumId: albumId }
        }).done(function(response) {
            var response = jQuery.parseJSON(response );
            var showBtn = false;
            fbhtml += "<div class='image_list addimage_box_col'>\
                <div class='row'>";
                    if(response['data'].length>0)
                    {
                        for(var x=0; x<response['data'].length; x++){
                            fbhtml += '<div class="col-lg-2 col-sm-3 col-xs-6" style="padding-top: 15px;"><div class="checkbox_left">';
                                fbhtml += '<input type="checkbox" class="css-checkbox" id="facebook_'+x+'" name="facebook[]" value="'+response['data'][x]['source']+'" />';
                                fbhtml += '<label class="css-label radGroup1" for="facebook_'+x+'"></label>';
                            fbhtml += '</div>';
                            fbhtml += '<div class="image_thumb">';
                                fbhtml += '<img class="bdr img-responsive center-block" src="'+response['data'][x]['source']+'" />';// style="width:100px !important; height:100px !important;" />';
                            fbhtml += '</div></div>';
                            showBtn = true;
                        }
                    }
                    else
                    {
                        fbhtml += '<div class="image_thumb">';
                        fbhtml += 'There are no image(s) in this album.';
                        fbhtml += '</div>';
                    }

                    fbhtml += "<input type='hidden' name='fb_copy' value='Copy Selected Files'>\
                </div>\
                <div class='row'>";
                    fbhtml += '<div class="col-lg-2 col-sm-3 col-xs-6" style="padding-bottom: 10px; padding-top: 10px;">';
                        if(showBtn == true)
                        {
                            fbhtml += "<input type='button' class='pink_btn' name='fb_copy' value='Copy Selected Files' onclick='moveImages($(\"#FBcontentFrm\").serialize())' />";
                        }
                    fbhtml += "</div>\
                </div>\
            </div>";
            $('#fbhtmlImage').html(fbhtml);
            $('#fbhtmlImage').show();
            $('#loader_img').hide();
        });
    }
</script>

<script>
/*
    function moveImages(){
        $.post(SiteURL+"wp-content/themes/mydomain/moveSelectedImages.php", $("#FBcontent").serialize(),function(data){
            alert(data);

            } );
    }*/
</script>


我看不出您在哪里设置
$user
的值,我是在fbmain.php中设置的