Solved

Cannot get Twitter API 1.1 to work

Posted on 2013-06-18
3
942 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
  • 2
3 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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)

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now