desmondmorris / node-twitter

Client library for the Twitter REST and Streaming API's.
https://www.npmjs.com/package/twitter
MIT License
1.27k stars 237 forks source link

Internal Server Error Occurred #276

Open parmeet9891 opened 6 years ago

parmeet9891 commented 6 years ago

Whenever i tried to login, it gives internal server error occurred. Consumer key and Consumer Secret Key are static (which i generated) and getting auth token and auth access token dynamically, when any user enter its credentials in the app.

gettwitterData:['checkInstagramUserExist',function(err,cb){
 if(payloadData.TwitterAccessTokenKey && payloadData.TwitterAccessTokenSecret && payloadData.email){
                var client = new Twitter({
                    consumer_key: 'CONSUMER_KEY',
                    consumer_secret: 'CONSUMER_SECRET_KEY',
                    access_token_key: payloadData.TwitterAccessTokenKey,
                    access_token_secret: payloadData.TwitterAccessTokenSecret
                });
                client.get('statuses/user_timeline', {q: 'node.js'}, function(error, tweets,response) {
                    if(tweets && tweets.length){
                        id=tweets[0].user.id
                        follower=tweets[0].user.followers_count
                        followed=tweets[0].user.friends_count
                        fullName=tweets[0].user.name
                        profilePicture=tweets[0].user.profile_image_url
                        if(parseInt(follower)<1){
                            callback('Cant sign up.You don’t have enough followers')
                        }else{
                            socialNetworkData.push({
                                socialLoginId:id,
                                followers:follower,
                                following:followed,
                                type:'TWITTER',
                                isAccountActive:true,
                            })
                            cb(null)
                        }
                    }else{
                        cb(null)
                    }
                });
            }else{
                cb(null)
            }
        }]