2012-03-08 2 views
0

FB 크레딧을 구현하기 위해 official tutorial을 따르지만 작동하지 않습니다.Facebook 크레딧 구현의 잘못된 점

코드가 실행 중인지 확인하기 위해 경고문을 추가했습니다. 경고 메시지에서 js 오류가없고 FB.ui가 호출되고 있음을 확신합니다. 콜백 함수에도 경고 메시지가 있지만 응답을받지 못했습니다.

나는 코드에서 무엇이 잘못 됐는지 알아 내려고 5 시간 이래로 머리를 아프게하고있다. 어떤 사람이 나를 도울 수 있습니까? 응용 프로그램에

추가 정보 :

  • 게시하지 않습니다 (샌드 박스 모드 사용)

    • 캔버스 응용 프로그램
    • 는 회사를 등록하지 않습니다. FB는 내가 나중에 할 수 있다고 말하면서 방금 나라를 정했다. 나는 은행 계좌 정보 나 FB 실 거예요 (인터페이스에서)를 변경할 수 있기 때문에 줄 필요가있는 결론
    다음

    Tool tip says, I can do it later as it is only mandatory for payments

    가 buy.php입니다 올 필요가 있기 때문에 내가 등록하지 않은 당신이 경고 전화를 통지하는 경우

    <?php 
    include_once '/Config.php'; 
    include_once '/fb-sdk/facebook.php'; 
    ?> 
    <html> 
        <head> 
         <title>My Facebook Credits Page</title> 
        </head> 
        <body> 
    <div id="fb-root"></div> 
    <script src="http://connect.facebook.net/en_US/all.js"></script> 
    <script> 
        FB.init({ 
        appId : '<?php echo Config::$appId?>', 
        status : true, // check login status 
        cookie : true, // enable cookies to allow the server to access the session 
        xfbml : true, // parse XFBML 
        channelUrl : 'http://localhost/buy.php', // channel.html file 
        oauth : true // enable OAuth 2.0 
        }); 
    
    var callback = function(data) { 
        if (data['order_id']) { 
         alert('called back'); 
         return true; 
        } else { 
         //handle errors here 
         alert('some error'); 
         return false; 
        } 
        }; 
    
    function placeOrder(){ 
    
        alert('in placeOrder()'); 
    
        var order_info = 'myorderinfo'; 
        alert('creating obj'); 
    
        var obj = { 
          method: 'pay', 
          order_info: order_info, 
          action: 'buy_item', 
          dev_purchase_params: {'oscif': true} 
          }; 
        alert('calling ui'); 
        FB.ui(obj, callback); 
    
    } 
    
    </script> 
    
    <input type="button" value="post" onclick="postFeed()" /> 
    <input type="button" value="Buy" onclick="placeOrder()" /> 
    </body> 
    </html> 
    

    , 나는 순서대로 경고 메시지를 얻고있다

      'placeOrder에서()'
    1. 'OBJ 만들기'
    2. '호출을 FB.ui'

    이 너무 콜백 함수에 경고 메시지가 있지만 그들은에

    를 호출되지 않습니다 이 벌금과 포 노력

    function postFeed(){ 
        alert('in postFeed()'); 
        FB.ui(
           { 
           method: 'feed', 
           name: 'Facebook Dialogs', 
           link: 'https://developers.facebook.com/docs/reference/dialogs/', 
           picture: 'http://fbrell.com/f8.jpg', 
           caption: 'Reference Documentation', 
           description: 'Dialogs provide a simple, consistent interface for applications to interface with users.' 
           }, 
           function(response) { 
           if (response && response.post_id) { 
            alert('Post was published.'); 
           } else { 
            alert('Post was not published.'); 
           } 
           } 
          ); 
    } 
    

    FB는 "postFeedback"의 클릭 이벤트에서 제대로 내가 구현 한 공급 후 기능을 inited는과라고 확인 나는 또한 https://developers.facebook.com/docs/authentication/signed_request/

    에 주어진 예제를 사용하여 callback.php을 구현 한

    내 벽에 고통 피드 네, 응용 프로그램 설정을 제대로

    callback.php

    <?php 
    
    include_once 'Config.php'; 
    
    mysql_connect('localhost','root',''); 
    mysql_select_db("precious_world"); 
    
    //var_dump($_REQUEST); 
    //dump the request into the db 
    $request = join(':', $_REQUEST); 
    $request = mysql_real_escape_string($request); 
    $query = "insert into fbcredits_callback(data)values('$request')"; 
    $result = mysql_query($query); 
    
    $fb_signed_req = $_REQUEST['signed_request']; 
    
    echo parse_signed_request($signed_request, Config::$appSecret); 
    
    function parse_signed_request($signed_request, $secret) { 
        list($encoded_sig, $payload) = explode('.', $signed_request, 2); 
    
        // decode the data 
        $sig = base64_url_decode($encoded_sig); 
        $data = json_decode(base64_url_decode($payload), true); 
    
        if (strtoupper($data['algorithm']) !== 'HMAC-SHA256') { 
        error_log('Unknown algorithm. Expected HMAC-SHA256'); 
        return null; 
        } 
    
        // check sig 
        $expected_sig = hash_hmac('sha256', $payload, $secret, $raw = true); 
        if ($sig !== $expected_sig) { 
        error_log('Bad Signed JSON signature!'); 
        return null; 
        } 
    
        return $data; 
    } 
    
    function base64_url_decode($input) { 
        return base64_decode(strtr($input, '-_', '+/')); 
    } 
    
    ?> 
    
    를 구성한

    이 파일에이 요청을 추적하기위한 전체 요청을 덤프하는 약간의 코드가 있습니다.

  • 답변

    1

    거기에 'localhost'가 있습니다. 채널 URL 중 하나이지만 크레딧 콜백 URL로 localhost를 사용하는 경우 Facebook이 연결할 수있는 방법이 없습니다 (따라서 크레딧 주문을 진행할 방법이 없습니다)

    +0

    aaaaaw 찌르다. 그걸 위해서. 내가 그 –

    +0

    그래서 순서를 확인하려면 내가 살아있는 URL을 언급해야 체크 할 것인가? 다른 방법은 없습니까? – Volatil3

    +0

    다른 URL을 사용할 수는 없지만 Facebook 서버에서 액세스 할 수 있어야합니다. – Gabriel