简体   繁体   English

chrome示例扩展无法正常工作

[英]chrome example extension not working

I have downloaded the code as it is from this link from chrome site 已从Chrome网站的此链接下载了代码

And tried to load the extension however the images do not get loaded and a small rectangle box is displayed.I tried to follow this link but no such error is present in the file i downloaded.Can anyone help please? 并尝试加载扩展,但图像没有加载,并显示一个小矩形框。我试图按照此链接但我没有下载的文件中出现此类错误。任何人都可以帮忙吗?

Quick Google search of that error and based on its description, it's a problem with the app's API key for Flickr . 快速Google搜索该错误并根据其描述,这是应用程序的Flickr API密钥的问题。 You can find the key in the example code at line 25. 您可以在第25行的示例代码中找到密钥。

searchOnFlickr_: 'https://secure.flickr.com/services/rest/?' +
  'method=flickr.photos.search&' +
  'api_key=90485e931f687a9b9c2a66bf58a3861a&' +

I encountered this before with this kittens example and you have to wait until the key is reactivated. 我之前遇到过这个小猫的例子,你必须等到重新激活密钥。 I'd suggest just getting started with another simple sample , such as "A browser action with a popup that changes the page color". 我建议刚刚开始使用另一个简单的示例 ,例如“带有弹出窗口的浏览器操作,可以更改页面颜色”。

What I did: 我做了什么:

  1. Go to "popup.js", find the query url, concatenate it, paste it to browser, found out the API key expired 转到“popup.js”,找到查询网址,连接它,将其粘贴到浏览器,发现API密钥已过期
  2. Search for "Flickr API key register", go to the registration page 搜索“Flickr API密钥寄存器”,进入注册页面
  3. Register for a Yahoo account 注册雅虎帐户
  4. Register a Flickr API key using that Yahoo account 使用该Yahoo帐户注册Flickr API密钥
  5. Replace the old API key in the query url with the one you just created, and enter that in the browser, confirm that it works 将查询网址中的旧API密钥替换为您刚创建的密钥,并在浏览器中输入该密钥,确认其有效
  6. Replace the old API key in the popup.js with the new one 用新的替换popup.js中的旧API密钥
  7. Now when you click the extension button again, it should show kitten pictures. 现在,当您再次单击扩展按钮时,它应显示小猫图片。

Finding out where the problem lies is not as hard as you may think. 找出问题所在并不像你想象的那么难。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM