Problem with 'object undefined' in custom facebook newsfeed plugin
Hi I'm writing a plugin to retrieve the news feed from facebook. I'm getting the expected results from facebook but my plugin gives a 'undefined object' error even when its not rendering anything.
Could someone please look at my code and maybe give me a pointer where the error(s) are?
- // JavaScript Document
(function($){
$.fn.fbFeed = function(options){
var opts ={
username: 'exiledscot1',
count: 5,
refresh_interval: null
};
if(options){$.extend(opts,options);}
return this.each(function(){
$this = $(this);
console.log($this);
var myUrl ="http://graph.facebook.com/'+opts.username+'/feed?limit='+opts.count+'&callback=?";
$.getJSON(myUrl,function(json){
markup='<ul class="message_list">';
$.each(json.data,function(i,fb){
markup+='<li>';
markup +='<a href="#" class="message_avatar"><img width="48" height="48" border="0" src="https://graph.facebook.com/'+fb.from.id+'/picture"></a>';
markup+=fb.message+'</li>';
});
markup+='</ul>';
$this.html(markup);
});
});
};
})(jQuery);
Im calling this with this javascript
- <script type='text/javascript'>
- $(document).ready(function(){
-
- $(".facebookfeed").fbFeed();
- });
- </script>