Asp.net API错误代码:191,facebook错误

Asp.net API错误代码:191,facebook错误,asp.net,facebook,Asp.net,Facebook,我在网上找到了这些有用的代码,但是当我运行代码并单击“发布的墙贴”时,我得到了这个错误 API Error Code: 191 API Error Description: The specified URL is not owned by the application Error Message: redirect_uri is not owned by the application. 如何修复此代码 谢谢 <!DOCTYPE html> <html xmlns="

我在网上找到了这些有用的代码,但是当我运行代码并单击“发布的墙贴”时,我得到了这个错误

API Error Code: 191  API Error Description: The specified URL is not
owned by the application  Error Message: redirect_uri is not owned by
the application.
如何修复此代码

谢谢

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">    
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>        
    <title>New Graph api & Javascript Base FBConnect Tutorial | Thinkdiff.net</title>    
</head>
<body>        
    <div id="fb-root"></div>        
    <script type="text/javascript">
        window.fbAsyncInit = function() {                
            FB.init({appId: '420291518023354', status: true, cookie: true, xfbml: true}); 

            /* All the events registered */                
            FB.Event.subscribe('auth.login', function(response) {                   
                // do something with response                    
                login();                
            });
            FB.Event.subscribe('auth.logout', function(response) {                    
                // do something with response                    
                logout();                
            });
            FB.getLoginStatus(function(response) {                    
                if (response.session) {                        
                // logged in and connected user, someone you know                        
                login();                    
                }                
            });            
        };

        (function() {                
            var e = document.createElement('script');                
            e.type = 'text/javascript';                
            e.src = document.location.protocol +                    
                '//connect.facebook.net/en_US/all.js';                
            e.async = true;                
            document.getElementById('fb-root').appendChild(e);            
        }());

        function login(){                
            FB.api('/me', function(response) {                    
                document.getElementById('login').style.display = "block";                    
                document.getElementById('login').innerHTML = response.name + " succsessfully logged in!";                
            });            
        }

        function logout(){                
            document.getElementById('login').style.display = "none";            
        }

        //stream publish method            
        function streamPublish(name, description, hrefTitle, hrefLink, userPrompt){                
            FB.ui(                
            {
            method: 'stream.publish',                    
            message: '',                    
            attachment: {                        
                name: name,                        
                caption: '',                        
                description: (description),                        
                href: hrefLink                    
            },
            action_links: [                        
                { text: hrefTitle, href: hrefLink }                    
            ],
            user_prompt_message: userPrompt
            },
            function(response) {

            });
        }
        function showStream(){
            FB.api('/me', function(response) {
                //console.log(response.id);
                streamPublish(response.name, 'Thinkdiff.net contains geeky stuff', 'hrefTitle', 'http://localhost:3000/', "Share thinkdiff.net");
            });
        }

        function share(){
            var share = {
                method: 'stream.share',
                u: 'http://thinkdiff.net/'
            };

            FB.ui(share, function(response) { console.log(response); });
        }

        function graphStreamPublish(){
            var body = 'Reading New Graph api & Javascript Base FBConnect Tutorial';
            FB.api('/me/feed', 'post', { message: body }, function(response) {
                if (!response || response.error) {
                    alert('Error occured');
                } else {
                    alert('Post ID: ' + response.id);
                }
            });
        }

        function fqlQuery(){
            FB.api('/me', function(response) {
                 var query = FB.Data.query('select name, hometown_location, sex, pic_square from user where uid={0}', response.id);
                 query.wait(function(rows) {

                   document.getElementById('name').innerHTML =
                     'Your name: ' + rows[0].name + "<br />" +
                     '<img src="' + rows[0].pic_square + '" alt="" />' + "<br />";
                 });
            });
        }

        function setStatus(){
            status1 = document.getElementById('status').value;
            FB.api(
              {
                method: 'status.set',
                status: status1
              },
              function(response) {
                if (response == 0){
                    alert('Your facebook status not updated. Give Status Update Permission.');
                }
                else{
                    alert('Your facebook status updated');
                }
              }
            );
        }
    </script>

    <h3>New Graph api & Javascript Base FBConnect Tutorial | Thinkdiff.net</h3>
    <p><fb:login-button autologoutlink="true" perms="email,user_birthday,status_update,publish_stream"></fb:login-button></p>

    <p>
        <a href="#" onclick="showStream(); return false;">Publish Wall Post</a> |
        <a href="#" onclick="share(); return false;">Share With Your Friends</a> |
        <a href="#" onclick="graphStreamPublish(); return false;">Publish Stream Using Graph API</a> |
        <a href="#" onclick="fqlQuery(); return false;">FQL Query Example</a>
    </p>

    <textarea id="status" cols="50" rows="5">Write your status here and click 'Status Set Using Legacy Api Call'</textarea>
    <br />
    <a href="#" onclick="setStatus(); return false;">Status Set Using Legacy Api Call</a>

    <br /><br /><br />
    <div id="login" style ="display:none"></div>
    <div id="name"></div>

</body>

新图形api和Javascript基础FBConnect教程| Thinkdiff.net
window.fbAsyninit=函数(){
init({appId:'420291518023354',状态:true,cookie:true,xfbml:true});
/*所有事件都已注册*/
订阅('auth.login',函数(响应){
//做些有反应的事情
登录();
});
FB.Event.subscribe('auth.logout',函数(响应){
//做些有反应的事情
注销();
});
FB.getLoginStatus(函数(响应){
if(response.session){
//已登录并已连接的用户,您认识的人
登录();
}                
});            
};
(函数(){
var e=document.createElement('script');
e、 类型='text/javascript';
e、 src=document.location.protocol+
“//connect.facebook.net/en_US/all.js”;
e、 异步=真;
document.getElementById('fb-root').appendChild(e);
}());
函数login(){
api('/me',函数(响应){
document.getElementById('login').style.display=“block”;
document.getElementById('login')。innerHTML=response.name+“成功登录!”;
});            
}
函数注销(){
document.getElementById('login').style.display=“无”;
}
//流发布方法
函数streamPublish(名称、描述、hrefTitle、hrefLink、userPrompt){
FB.ui(
{
方法:“stream.publish”,
消息:“”,
附件:{
姓名:姓名,,
标题:'',
描述:(描述),
href:hrefLink
},
行动链接:[
{文本:hrefTitle,href:hrefLink}
],
用户提示消息:用户提示
},
功能(响应){
});
}
函数showStream(){
FB.api('/me',函数(响应){
//console.log(response.id);
streamPublish(response.name,'Thinkdiff.net包含极客的东西,'hrefitle','http://localhost:3000/“共享thinkdiff.net”);
});
}
函数共享(){
风险值份额={
方法:“stream.share”,
u:'http://thinkdiff.net/'
};
ui(共享,函数(响应){console.log(响应);});
}
函数图StreamPublish(){
var body='阅读新图形api和Javascript基础FBConnect教程';
api('/me/feed',post',{message:body},函数(响应){
如果(!response | | response.error){
警报(“发生错误”);
}否则{
警报('Post ID:'+response.ID);
}
});
}
函数fqlQuery(){
FB.api('/me',函数(响应){
var query=FB.Data.query('select name,homightry\u location,sex,pic\u square from user where uid={0}',response.id);
query.wait(函数(行){
document.getElementById('name').innerHTML=
“您的姓名:”+行[0]。姓名+“
”+ ''+“
”; }); }); } 函数setStatus(){ status1=document.getElementById('status')。值; FB.api( { 方法:“status.set”, 状态:状态1 }, 功能(响应){ 如果(响应==0){ 警报('您的facebook状态未更新。请授予状态更新权限'); } 否则{ 警报(“您的facebook状态已更新”); } } ); } 新图形api和Javascript基础FBConnect教程| Thinkdiff.net

| | |

在此处写入您的状态,然后单击“使用旧Api调用设置状态”




这是因为facebook的权限。当你创建一个新的FB应用程序时,有一个名为“应用程序域”的字段,你只需要从该地址调用FB应用程序,否则它将无法工作

例如,如果您有应用程序域,并且您尝试从(不使用www)访问,则会出现该错误

我建议您在“应用程序域”中存储所有可能的域名组合,包括别名和子域

希望这对你有帮助