如何在Google Chrome扩展程序中使用Facebook Graph API? [英] How do you use the Facebook Graph API in a Google Chrome Extension?

查看:116
本文介绍了如何在Google Chrome扩展程序中使用Facebook Graph API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用 https://graph.facebok.com/id

时,我一直在尝试访问可用的信息/ a>概念,但是根据我发现的不同代码片段,无法调用或返回任何信息。我不知道我是否正确使用JSON功能。



例如,

  var testlink =https://graph.facebook.com/\"+id+\"/&callback=?; 
$ .getJSON(testlink,function(json){
var test;
$ .each(json.data,function(i,fb){
test =& ul>+ json.name +< / ul>;
});
});

在这段代码中,我试图返回测试变量的名称。当我在Google Chrome扩展程序中使用它时,它只返回一个空白页。



或者,我也试图在我的Google Chrome中使用Facebook Javascript SDK扩展,但我不确定注册API密钥时应该使用什么网站。

解决方案

我相信你需要在建立OAuth会话或提供您的API密钥之前,您可以与FB交谈。这是一段时间以来,我搞砸了FB api,但我很确定你必须先注册才能使用api。



这是一些可能有用的东西,但它是一个JavaScript控制台,可以让您测试您的代码! http://developers.facebook.com/tools/console/


I have been trying to access the information available when using the https://graph.facebok.com/id concept through JSON but have been unable to call or return any information based on different snippets of code I've found around. I'm not sure if I'm using the JSON function correctly or not.

For example,

var testlink = "https://graph.facebook.com/"+id+"/&callback=?";
   $.getJSON(testlink,function(json){
   var test;
  $.each(json.data,function(i,fb){
   test="<ul>"+json.name+"</ul>";
   });
});

In this code, I am trying to return in the test variable the name. When I use this in a Google Chrome Extension, it just returns a blank page.

Alternatively, I've been also trying to use the Facebook Javascript SDK in my Google Chrome extension, but I am unsure what website I should be using when signing up for an API Key.

解决方案

I believe that you need to establish either an OAuth session or provide your API key before you can talk to FB. It's been a while since I messed around with FB api but, I'm pretty sure you have to register before you can use the api.

Here's something that might be useful though, it's a javascript console for Facebook which would allow you to test out your code! http://developers.facebook.com/tools/console/

这篇关于如何在Google Chrome扩展程序中使用Facebook Graph API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆