?
Solved

Cannot get Twitter API 1.1 to work

Posted on 2013-06-18
3
Medium Priority
?
948 Views
Last Modified: 2013-06-22
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
Comment
Question by:mike99c
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 1000 total points
ID: 39260212
0
 

Author Comment

by:mike99c
ID: 39260231
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
 
LVL 82

Expert Comment

by:leakim971
ID: 39260273
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

Featured Post

Basic Security of Your VPC

So, you’ve got this shiny new VPC and a fancy new application configured on your EC2 servers ready to go. This application is only accessible from your computer, which is great for security, but you need your users to be able to access it! So, what’s the easiest way to do this?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question