1

오픈 그래프로 Facebook에 내 이야기를 게시하는 데 문제가 있습니다. OrionHub에 사이트를 시작했습니다. 이것은 내 코드입니다.Facebook 공개 그래프로 이야기를 게시 할 때 OAuthException이 발생했습니다.

나는 이미 작업과 개체를 만들었습니다.

index.html을

<!DOCTYPE html> 
<html> 
<head> 
<meta charset=utf-8 /> 
    <meta property="fb:app_id" content="APP_ID" /> 
    <meta property="og:type" content="pruebablackbear:app" /> 
    <meta property="og:url" content="http://facebookapp.orionhub.org:8080/index.html" /> 
    <meta property="og:title" content="Sample app" /> 
    <meta property="og:image" content="https://fbstatic-a.akamaihd.net/images/devsite/attachment_blank.png" /> 
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> 

<title>My Facebook App</title> 
</head> 
<body> 
<div id="fb-root"></div> 
<script> 
    window.fbAsyncInit = function() { 
    // init the FB JS SDK 
    FB.init({ 
     appId  : '124306291113571',      // App ID from the app dashboard 
     channelUrl : '//facebookapp.orionhub.org:8080/index.html', // Channel file for x-domain comms 
     status  : true,         // Check Facebook Login status 
     xfbml  : true         // Look for social plugins on the page 
    }); 

    // Additional initialization code such as adding Event Listeners goes here 
    }; 

    // Load the SDK asynchronously 
    (function(d, s, id){ 
    var js, fjs = d.getElementsByTagName(s)[0]; 
    if (d.getElementById(id)) {return;} 
    js = d.createElement(s); js.id = id; 
    js.src = "//connect.facebook.net/en_US/all.js"; 
    fjs.parentNode.insertBefore(js, fjs); 
    }(document, 'script', 'facebook-jssdk')); 
</script> 
<h2 class="saludo">HELLO </div> 
<button class = 'loginButton'> Press me to Login </button> 
<button class = 'publiSH'> Publicar una historia </button> 

<script src="main.js"></script> 
</body> 
</html> 

main.js

$('.loginButton').click(function(){ 

    // FACEBOOK LOGIN 
    FB.login(function(response) { 

      // GETTING FACEBOOK DATA 

     FB.api('/me', function(response) { 

     // stuff you want to happen after getting data goes here 
     // alert(response.name); 
     // console.log(response); 
     $(".saludo").append(response.name); 

     }); //FB.api 

     // END - FACEBOOK DATA 


    },{scope: 'publish_actions'}); //FB.login 

    // END - FACEBOOK LOGIN 



}); //click 

$('.publish').click(function(){ 

    FB.getLoginStatus(

    function(response){ 
     // alert(response.status); 
      if(response.status=="connected"){ 
       //stuff to happen after click goes here. E.g. 
      FB.api(
       'me/objects/pruebablackbear:app', 
       'post', 
        { 
        app:"http://facebookapp.orionhub.org:8080/index.html", 
        privacy:{'value': 'SELF'} 
        }, 
    function(response) { 
    // handle the response 
        if (!response || response.error) { 
        alert(JSON.stringify(response.error)); 
        alert('Error Occurred ' + response.responseText + " " + response.error.responseText); 
      } else { 
        alert('Published: ' + response.id); 
      } 
     } 
     ); 

        window.open('http://www.google.com','mywindow','width=400,height=200'); 
       }else{ 
       alert("Please Login"); 
       } 

     } 
    ); 

}); //click 

나는 제대로 로그인 할 수 있습니다,하지만 난 이야기를 게시하려고 할 때이 메시지가 얻을 :

{"message":"(#100) The parameter object is required","type":"OAuthException","code":100} 

무엇이 잘못 되었나요?

답변

0

당신은 FB.api에 전달하는 자바 스크립트 객체의 속성 이름으로 app 사용했다 :

 FB.api(
      'me/objects/pruebablackbear:app', 
      'post', 
       { 
       app:"http://facebookapp.orionhub.org:8080/index.html", 
       privacy:{'value': 'SELF'} 
       }, 

을하지만 당신의 행동의 이름이 보인다 - 매개 변수는이 같은 이름을 사용해야합니다 오브젝트이 작업을 수행 할 때 호출됩니다. 나는 그게 어떻게 보일지 생각 :

 FB.api(
      'me/objects/pruebablackbear:app', 
      'post', 
       { 
       banana:"http://facebookapp.orionhub.org:8080/index.html", 
       privacy:{'value': 'SELF'} 
       }, 

편집 : 개체가 banana라는 이름의 경우

그래서, 그것은 것

 FB.api(
      'me/pruebablackbear:crear', 
      'post', 
       { 
       app: 'http://facebookapp.orionhub.org:8080/index.html', 
       privacy: {value: 'SELF'} 
       }, 
+0

하지만, 내 행동은 " crear "(작성을위한 스페인어)이고"app "는 내 객체입니다. –

+0

대신에 다른 부분을 대체하십시오 :''me/objects/pruebablackbear : crear ',' – CBroe

+0

응답을 주셔서 감사합니다 :'{ "message": "예기치 않은 오류가 발생했습니다. 나중에 다시 시도하십시오. . ","type ":"OAuthException ","code ": 2}' –