Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Callback function doesn't fire when including Twitter #194

Open
ricardo-lewis opened this issue Jul 5, 2016 · 13 comments
Open

Callback function doesn't fire when including Twitter #194

ricardo-lewis opened this issue Jul 5, 2016 · 13 comments

Comments

@ricardo-lewis
Copy link

I can access Instagram and Facebook and the callback function will execute. But when I add Twitter, or even just access Twitter by itself, the callback function never runs.

@HartLarsson
Copy link
Contributor

if callback is not firing could be a problem that twitter not collect nothing and/or nr. of post collected are < of max post you specify.
I've put a fix in my version, a fix not made by me but i've applied and works great. Feel free to to use my forked version to test

@ricardo-lewis
Copy link
Author

Less than the max number of posts makes sense, thanks. I'll have a look at your fix.

@ricardo-lewis
Copy link
Author

ricardo-lewis commented Jul 8, 2016

@HartLarsson I tried using your version but the callback function still doesn't fire unless I remove Twitter. It shouldn't be a big deal, I think it's only because the Twitter account only has 3 posts in it :-)

@HartLarsson
Copy link
Contributor

can you provide me your sample page so i can debug?

@ricardo-lewis
Copy link
Author

Not really, I'm developing locally. I'm think the problem will go away once I have more than 3 tweets on that account.

@HartLarsson
Copy link
Contributor

no, even with one tweet only, it works. so the problem is not on the js.

@ricardo-lewis
Copy link
Author

Here is the JS that powers the social feed (names have been changed to protect the innocent):

$('.social-feed-container').socialfeed({
        'twitter':{
            accounts: ['@atmwebdev'],
            limit: 4,
            consumer_key: 'ABCDEF',
            consumer_secret: 'ABCDEF'

        },  
      'instagram':{
          accounts: ['@this_user_works_fine'],  
          limit: 4,
           client_id: 'ABCDEF',      
            access_token: 'ABCDEF'
      },
        'facebook':{
            accounts: ['@atmwebdev'],
            limit: 4,
            access_token:'ABCDEF'
        },
      // GENERAL SETTINGS
      length:100,
      template: window.social_feed_template,
      show_media: true,
      callback: function() {                         
            log("All posts collected!");
        }
  });

And as I've already mentioned, the final callback function only triggers when I comment out the Twitter section entirely.

This is the HTML, which seems to work fine regardless:

<div class="social-feed"><div class="row"><div class="column"><ul class="medium-block-grid-3 large-block-grid-4 social-feed-container"></ul></div></div></div>

The social feed template uses LI tags to enclose each post.

@ricardo-lewis
Copy link
Author

@HartLarsson when I set the Twitter limit parameter to less than the amount of tweets available in the timeline, the callback function executes. There are only 3 tweets on my timeline, when I set the limit to 2, it all works fine.

@HartLarsson
Copy link
Contributor

this thing have no sense really, looking the piece of code that calculate the ammount of feed to load:

 utility: {
                    getPosts: function(json) {
                        if (json) {
                            // fix callback
                            console.log(json.length);
                            if(json.length < options.twitter.limit)
                                posts_to_load_count -= options.twitter.limit - json.length;
                            $.each(json, function() {
                                var element = this;
                                var post = new SocialFeedPost('twitter', Feed.twitter.utility.unifyPostData(element));
                                post.pushData();
                            });
                        }
                    },

must work!
I've added a console.log(json.length); to see in the log how many post it collect.
Please add the modification and see how many are returned.

@ricardo-lewis
Copy link
Author

I added the line:

console.log(json.length);

And it returns the correct number, which is the limit option for Twitter (above).

If I set the Twitter limit to a number (e.g. 20) higher than the actual number of tweets in the timeline (currently 7) then the callback never executes.

Which is fine, I'm sure the author never imagined a scenario like this.

@HartLarsson
Copy link
Contributor

is strange must return 7, the length of the feed recovered by twitter and not 0 (the limit you put).
I've tested in my version and it works as intended for me. Probably there is an error to check in the json return. Yuo can provide me in private mode the twitter parameters you use so i can debug with a empty twitter like yours?

@ricardo-lewis
Copy link
Author

Honestly I just made a twitter account specifically for testing. It's free and apparently it's the correct thing to do since Twitter doesn't have a sandbox mode. Just try that, then you have a Twitter timeline with nothing in it.

@nicosuria
Copy link

There's a PR addressing this: #173

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants