dongzhi9192 2014-08-24 09:55
浏览 105
已采纳

当点击fb连接按钮时没有任何反应

when click on fb connect button nothing happens i=I have downloaded the following code from phpgang.com I have downloaded many php script no one is working please check the below code please. my code is below:

    <?php
    session_start();
    $config['callback_url']         =   'CALL BACK URL/?fbTrue=true'; //   /?fbTrue=true is required.

    //Facebook configuration
    $config['App_ID']      =   'YOUR_APPLIVATION_ID';
    $config['App_Secret']  =   'YOUR_APPLIVATION_SECRET'; 
    require 'src/facebook.php';

    // Create our Application instance (replace this with your appId and secret).
    $facebook = new Facebook(array(
      'appId'  => $config['App_ID'],
      'secret' => $config['App_Secret'],
      'cookie' => true
    ));


    if(isset($_POST['status']))
    {
        $group_id = $_POST['group'];

        $publish = $facebook->api('/'.$group_id.'/feed', 'post',
                array('access_token' => $_SESSION['token'],
                'message'=> 'Testing',
                'from' => $config['App_ID'],
                'to' => $group_id,
                'caption' => 'PHP Gang',
                'name' => 'PHP Gang',
                'link' => 'http://www.phpgang.com/',
                'picture' => 'http://www.phpgang.com/wp-content/themes/PHPGang_v2/img/logo.png',
                'description' => 'Testing with PHPGang.com Demo'
                ));
            $publish = $facebook->api('/'.$group_id.'/feed', 'post',
            array('access_token' => $_SESSION['token'],'message'=>$_POST['status'] .'   via PHPGang.com Demo',
            'from' => $config['App_ID']
            ));
            $message = 'Status updated.<br>';
            $graph_url_groups = "https://graph.facebook.com/v2.1/me/groups?access_token=".$_SESSION['token'];
    //    echo $graph_url_pages;
        $groups = json_decode(file_get_contents_curl($graph_url_groups)); // get all groups information from above url.

        $dropdown = "";
        for($i=0;$i<count($groups->data);$i++)
        {
            $dropdown .= "<option value='".$groups->data[$i]->access_token."-".$groups->data[$i]->id."'>".$groups->data[$i]->name."</option>";
        }

        $content = '
        <style>
        #status
        {
            width: 357px;
            height: 28px;
            font-size: 15px;
        }
        </style>
        '.$message.'
        <form action="index.php" method="post">
        Select Group on which you want to post status: <br><select name="group" id="status">'.$dropdown.'</select><br><br>
        <input type="text" name="status" id="status" placeholder="Write a comment...." />
        <input type="submit" value="Post On My Group!" style="padding: 5px;" />
        <form>';
    }
    elseif(isset($_GET['fbTrue']))
    {
        $token_url = "https://graph.facebook.com/v2.1/oauth/access_token?"
            . "client_id=".$config['App_ID']."&redirect_uri=" . urlencode($config['callback_url'])
            . "&client_secret=".$config['App_Secret']."&code=" . $_GET['code'];

        $response = file_get_contents_curl($token_url);   // get access token from url
        $params = null;
        parse_str($response, $params);

        $graph_url = "https://graph.facebook.com/v2.1/me?access_token=" 
            . $params['access_token'];
            $_SESSION['token'] = $params['access_token'];
        $user = json_decode(file_get_contents_curl($graph_url)); // Get user information from given url


        $graph_url_groups = "https://graph.facebook.com/v2.1/me/groups?access_token=".$_SESSION['token'];
        $groups = json_decode(file_get_contents_curl($graph_url_groups)); // get all groups information from above url.


        $dropdown = "";
        for($i=0;$i<count($groups->data);$i++)
        {
            $dropdown .= "<option value='".$groups->data[$i]->id."'>".$groups->data[$i]->name."</option>";
        }


        $content = '
        <style>
        #status
        {
            width: 357px;
            height: 28px;
            font-size: 15px;
        }
        </style>
        '.$message.'
        <form action="index.php" method="post">
        Select Group on which you want to post status: <br><select name="group" id=status>'.$dropdown.'</select><br><br>
        <input type="text" name="status" id="status" placeholder="Write a comment...." />
        <input type="submit" value="Post On My Page!" style="padding: 5px;" />
        <form>';
    }
    else
    {
        $content = 'Connect only &nbsp;&nbsp;<a href="https://www.facebook.com/dialog/oauth?client_id='.$config['App_ID'].'&redirect_uri='.$config['callback_url'].'&scope=email,user_about_me,publish_stream,publish_actions,user_groups"><img src="./images/login-button.png" alt="Sign in with Facebook"/></a>';
    }

    echo $content;

    function file_get_contents_curl($url) {
        $ch = curl_init();

        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Set curl to return the data instead of printing it to the browser.
        curl_setopt($ch, CURLOPT_URL, $url);

        $data = curl_exec($ch

);
    curl_close($ch);

    return $data; } ?>
  • 写回答

1条回答 默认 最新

  • dousuo2812 2014-08-25 17:06
    关注

    You won't be able to use a local callback URL - your request to Facebook will require a public callback URL as it won't be able to make a callback to localhost.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 算法题:数的划分,用记忆化DFS做WA求调
  • ¥15 chatglm-6b应用到django项目中,模型加载失败
  • ¥15 武汉岩海低应变分析软件,导数据库里不显示波形图
  • ¥15 CreateBitmapFromWicBitmap内存释放问题。
  • ¥30 win c++ socket
  • ¥30 CanMv K210开发板实现功能
  • ¥15 C# datagridview 栏位进度
  • ¥15 vue3页面el-table页面数据过多
  • ¥100 vue3中融入gRPC-web
  • ¥15 kali环境运行volatility分析android内存文件,缺profile