简体   繁体   English

如何在我自己的Facebook应用程序中重用Facebook的电影自动完成功能?

[英]How do I reuse Facebook's Movie Autocomplete in my own Facebook App?

On Facebook, when you go to, Edit My Profile > Arts and Entertainment, there is a "Movies" autocomplete widget that suggests movies as you type them in. 在Facebook上,当您转到“编辑我的个人资料”>“艺术与娱乐”时,会有一个“电影”自动完成小部件,可以在您输入电影时建议电影。

So if you type in "Jones", it will start to suggest: 因此,如果您输入“琼斯”,它将开始建议:

  • Indiana Jones 印第安纳琼斯
  • Bridget Jones' Diary 布里奇特琼斯的日记
  • Indiana Jones and the Kingdom of the Crystal Skull 印第安纳琼斯和水晶头骨王国

Can I reuse this widget (or its data) in my own Facebook app? 我可以在自己的Facebook应用程序中重用此小部件(或其数据)吗?

I would like to give my users the ability to create lists of movies, and I think this feature would be a lot better than having them manually type out the full names of each movie on their list. 我想让我的用户能够创建电影列表,我认为这个功能比让他们手动输入列表中每部电影的全名要好得多。

I found one potentially relevant answer on stackoverflow ( How to consume Facebook's "autocomplete anything" suggest-style dropdown ) but the answer is 2 years old, and seems to reference an FBML tag called " typeahead " which is no longer in use. 我发现了一个计算器可能相关的答案( 如何消费Facebook的“自动完成任何事情”建议式下拉菜单 ),但得到的答复为2岁,似乎参照名为“一个FBML标签预输入 ”,这是不再使用。

Most searches for "Facebook autocomplete" talk about replicating the autocomplete feature for Facebook's messages, such as what is described here . 大多数“Facebook自动填充”搜索都在谈论复制Facebook消息的自动完成功能,例如此处描述的内容。 But obviously this isn't what I'm looking for, so I'm not finding any help. 但显然这不是我想要的,所以我找不到任何帮助。

If I can't reuse the exact widget that Facebook uses for this feature, is there a way I can feed the data that it draws upon into jQuery UI's autocomplete ? 如果我不能重复使用Facebook用于此功能的确切小部件,我是否可以将其绘制的数据提供给jQuery UI的自动完成

So far I can't find anything like this in Facebook's API, but I'd be surprised if there wasn't as I think a lot of people could use Facebook's autocomplete data in their own Facebook apps. 到目前为止,我在Facebook的API中找不到这样的东西,但如果没有,我会感到惊讶,因为我认为很多人可以在他们自己的Facebook应用程序中使用Facebook的自动完成数据。

Here is the closest thing to a solution I was able to write, using jQuery UI's autocomplete widget. 这是我能够使用jQuery UI的自动完成小部件编写的最接近解决方案的东西。 This solution doesn't act as a true autocomplete, because although typing in "Indiana" will suggest "Indiana Jones", typing in "Indiana Jo" will not suggest anything. 这个解决方案并不是一个真正的自动完成,因为虽然输入“Indiana”会提示“Indiana Jones”,但输入“Indiana Jo”并不会提出任何建议。 Perhaps someone else has a better solution? 也许别人有更好的解决方案?

    $( "#autocomplete" ).autocomplete({
    source: function( request, response ) {
        $.ajax({
            url: "https://graph.facebook.com/search",
            dataType: "jsonp",
            data: {
                type: "page",
                q: request.term
            },
            success: function( data ) {
                response( $.map( data.data, function( item ) {
                    if (item.category=="Movie") {
                        return {
                            value: item.name
                        }
                    }
                }));
            }
        });
    },
    minLength: 2
    });     

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

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