• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 957
  • Last Modified:

Cannot get Twitter API 1.1 to work

I have been using the Twitter API code below to list some Twitter feeds on a website. Unfortunately Twitter has made some changes which require you to autenticate yourself before you can use the script.

I understand you have to use oAuth to authenticate access to the API.
https://dev.twitter.com/docs/auth/oauth

Unfortunately I cannot understand how to integrate this into the script. Or is this something that has to be done separately?

JQTWEET = {
	
	// Set twitter username, number of tweets & id/class to append tweets
	user: 'twitterscreenname',
	numTweets: 2,
	appendTo: '#jstwitter',

	// core function of jqtweet
	loadTweets: function() {
		$.ajax({
			url: 'https://api.twitter.com/1.1/statuses/user_timeline.json',
			type: 'GET',
			dataType: 'jsonp',
			data: {
				screen_name: JQTWEET.user,
				include_rts: true,
				count: JQTWEET.numTweets,
				include_entities: true
			},
			success: function(data, textStatus, xhr) {

			 var html = '<div class="tweet">TWEET_TEXT';

				 // append tweets into page
				 for (var i = 0; i < data.length; i++) {
					$(JQTWEET.appendTo).append(
						html.replace('TWEET_TEXT', JQTWEET.ify.clean(data[i].text))
							.replace(/USER/g, data[i].user.screen_name)
							.replace('AGO', JQTWEET.timeAgo(data[i].created_at))
							.replace(/ID/g, data[i].id_str)
					);

				 }					
			}	

		});
		
	}, 
	
		
	/**
      * relative time calculator FROM TWITTER
      * @param {string} twitter date string returned from Twitter API
      * @return {string} relative time like "2 minutes ago"
      */
    timeAgo: function(dateString) {

	}, // timeAgo()
    
	
    /**
      * The Twitalinkahashifyer!
      * http://www.dustindiaz.com/basement/ify.html
      * Eg:
      * ify.clean('your tweet text');
      */
    ify:  {

    } // ify

	
};

$(document).ready(function () {
	// start jqtweet!
	JQTWEET.loadTweets();
});

Open in new window

0
mike99c
Asked:
mike99c
  • 2
1 Solution
 
leakim971PluritechnicianCommented:
0
 
mike99cAuthor Commented:
Thanks for the links but I have seens these before and simply cannot make any sense of them. I was hoping someone could provide actual examples.

Can the authentication be done client side inside the JQuery?
0
 
leakim971PluritechnicianCommented:
Can the authentication be done client side inside the JQuery?

No,
If you ask this a second time it look like you don't want to accept the new rules

That's why you see server side code each time you try to find an answer to your question
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now