mentions_timeline on my website


#1

Hello,

I try to put the mentions on my website with JS librarie jsOAuth-1.3.6.min.js.
When I do this

oauth = OAuth(options);
oauth.get("https://api.twitter.com/1.1/statuses/mentions_timeline.json", success, error);

function success(data){

var items = [];
$.each(data, function(key, val) {
	items.push('<li id="' + key + '">' + val + '</li>');
 });

$('<ul/>', {
	'class': 'my-new-list',
	html: items.join('')
}).appendTo('#test');
}

function error(data) {
	alert("something failed");
}

I have this in my div #test

<ul class="my-new-list">
<li id="text"></li>
<li id="xml"></li>
<li id="requestHeaders">objectObject</li>
<li id="responseHeaders">objectObject</li>
</ul>

My question is how can I do to have this json : https://dev.twitter.com/docs/api/1.1/get/statuses/mentions_timeline

Thank you


#2

Your mentions timeline is a feed built for your eyes only. If you’re going to display those tweets on a public website, it’s your responsibility to insure that you’re maintaining user privacy by not displaying tweets authored by protected users.

API v1.1 requires OAuth 1.0A, which prevents you from using it in a pure client-side Javascript environment like this.


#3

Thank you for your response.

My developpement is for my website administration. Nobody else can see it.

So if I can’t use Javascript for my authentification, what kind of language I should use ?


#4

Most server-side languages have OAuth libraries available. I would recommend tmhOAuth for PHP if you’re already familiar with PHP.


#5

Ok thank you.
Have a good day !


#6

Another question.
Is it possible to use classic ASP ?


#7

Yes – Feel free to use my ASPTwitter class as a starting point. The code already does OAuth authentication and gets tweets, and works with Twitter API 1.1:

http://www.timacheson.com/Blog/2013/jun/asptwitter


#8

please I want to show the mentions from people that show on my timeline
to feed it on my website
this code is right??
and then how to print Valuse??

require_once("twitteroauth/twitteroauth/twitteroauth.php");

$consumerkey = “”;
$consumersecret = “”;
$accesstoken = “”;
$accesstokensecret = “”;
function getConnectionWithAccessToken($cons_key, $cons_secret, $oauth_token, $oauth_token_secret) {
$connection = new TwitterOAuth($cons_key, $cons_secret, $oauth_token, $oauth_token_secret);
return $connection;
}

$connection = getConnectionWithAccessToken($consumerkey, $consumersecret, $accesstoken, $accesstokensecret);

$search = str_replace("#", “%23”, $search);
$tweets = $connection->get(“https://api.twitter.com/1/users/search.json?q="+$search+"&src=typd&result_type=mixed&count=4”);

echo json_encode($tweets);


#9

I would first recommend that you use [node:10248]. Create a search query for “to:screen_name” and then embed the resultant widget on your site.

If you want to take this server-side approach, make sure you’re using the latest version of twitteroauth. You want to use the [node:10287] API method from API v1.1. (You’re using the users/search method from API v1 in this example code, an API version that is now retired).


#10

thanx mr @episod … I dont want to use Embed method because I want to use different design.
I want use API method from API 1.1
but I didnt know how I can use it

first I should be use this URL:
https://api.twitter.com/1.1/search/tweets.json
what then??
I want ready example to edit and use it.
if I use this code
https://api.twitter.com/1.1/search/tweets.json?q=%23SalemAAlsaiary

what the commend to print the request??
echo xxx;


#11

Keep in mind that if you want to use your own design, you’ll still need to make it compliant with [node:142].

I would recommend that you explore the object that you get back after a successful request. Generally the object structure gets translated into a hash of some kind, and then you iterate through elements in a collection.

In the Search API, the tweets you’re looking for are in an array within the “statuses” node of the response hash. Each element of that array is tweet – [node:7286] gives you info on the fields within a tweet. Some you’ll want to use for display, some you won’t.