Twitter Library for ASP.NET MVC that implements REST API - asp.net

I been looking for a twitter lib for my ASP.NET NET MVC 3 software, but I need to implement the REST API functions that I nor found in Twitter Helper or Twitterizer. Rest API allow me to use a Find People query.
There is another one could solve my problem?

My suggestion would be to try looking into a library, such as TweetSharp that already has wrappers around a substantial amount of the Twitter API methods. If that doesn't work for you, consider writing your own wrapper around the methods you need using libraries such as HammockRest or RestSharp that have support for working with http, oauth and other such features that may assist you.

Looking better in Twitterizer I found what I need, perform Search People, and other functions. I recommend Twitterizer to use twitter in ASP.NET MVC 3, ´cause the oAuth process has a better code.
Here the Sample code to peform Search People in twitter using Twitterizer :
UserSearchOptions options = new UserSearchOptions();
options.NumberPerPage = 40;
options.Page = 1;
TwitterResponse<TwitterUserCollection> usersResponse = TwitterUser.Search(tokens,pesquisa.Conteudo,options);
if (usersResponse.Result == RequestResult.Success)
{
StringBuilder list = new StringBuilder();
foreach (var u in usersResponse.ResponseObject)
{
list2.Append(u.Name + "-" + u.Id);
}
ViewBag.Result_Twitter = list.ToString();
}

Related

Spring Social Twitter Authenticaion in asp.net

I'm designing a website using forms asp.net
I would like this website to view tweets for a from a twitter account timeline using spring social twitter API
the problem is when I i run the web page it show this error
The Twitter REST API v1 is no longer active. Please migrate to API
v1.1. https://dev.twitter.com/docs/api/1.1/overview.
I'm sure that I have the latest version of the library as it works fine with there console application sample code but they neither provide a sample for AS.NET forms nor a proper documentation
I'm really lost and I can't figure how to use it
anyway here's my code and I would really appreciate any help
string consumerKey = //my kry;
string consumerKeySecret = //my key secret;
string accessToken = //my token;
string accessTokenSecret = //my token secret;
ITwitter twitter = new TwitterTemplate(consumerKey, consumerKeySecret, accessToken, accessTokenSecret);
IList<Tweet> tweets = twitter.TimelineOperations.GetUserTimeline();
foreach (var tweet in tweets)
lbl.Text = lbl.Text + "\n" + tweet;
The API you are using seems to be deprecated.
I am personally used Tweetinvi for lots of developments related with Twitter and lots of features are already implemented.
Also it is compatible with Twitter 1.1.
Here is how to get the timeline of the connected user:
var user = User.GetLoggedUser();
var timeline = user.GetUserTimeline();

How do I do basic Auth in Zend Framework 2 http requests?

Good morning all,
I'm trying to call an api which requires basic authentication. I'm trying to use Zend Framework 2 Zend\Http\Request, and I'm not sure which the best way of doing Basic Auth is or should I manually set a header?
I'm trying to force myself to use ZF2 and stop using ZF1 so please bear with me, old habits die hard.
ZF2
$http= new Zend\Http\Request();
$http->setUri('https://api.my.tv/analytics/views/daily/');
$http->....
In ZF1 I used to do the following which is really nice and convenient.
$http = new \Zend_Http_Client();
$http->setUri('https://api.my.tv/analytics/views/daily/');
$http->setAuth($my_api_key, 'x', \Zend_Http_Client::AUTH_BASIC);
$request = $http->request(\Zend_Http_Client::POST);
Is there is a similar method available in ZF2 or should I write my own. To be honest I don't know if I'm better off just using guzzle.
Jujhar
The approach is exactly the same also with Zend\Http\Client:
$client = new \Zend\Http\Client();
$client->setAuth($user, $password, \Zend\Http\Client::AUTH_BASIC);
$client->setUri('http://api.buto.tv/analytics/views/daily/');
$client->setMethod(\Zend\Http\Request::METHOD_POST);
$response = $client->send();

Javascript and Wordpress

Two related questions:
Is there any good documentation on the Fusion Tables Javascript API? I've found a list of methods, but with little info on return values, semantics, or usage idioms.
Is there any guidance (or suggested plugins or idioms) for integrating the FT Javascript API into a locally hosted Wordpress site?
There is some documentation here:
https://developers.google.com/fusiontables/docs/v1/getting_started#JS
but I didn't find it very useful.
But this example, in the context of the Google Maps API I found very useful for the new API 1.0
https://googledrive.com/host/0B5KVZ6J1ohN_Q3ZqVkFGSGZ2cEE/custom%20markers%20code/customicons_viaApi.html
You'll need to view and save the source. Also if you search the FT tag for JSONP you will find many examples using the old pre 1.0 API but the concepts are the same, just the AJAX end point has changed and the need for an apiKey.
The basic idea is that any FT query will return a JSON object with both columns and rows members, very much like a CSV response.
As the example above shows:
function onDataFetched(data) {
var rows = data.rows;
var cols = data.cols;
...
}

ASP.net (VB code behind) JSON parsing facebook Graph API response

net but wanted to try to do this code in ASP.net instead of my normal classic ASP.
I have been trying to find code examples that would show me how to parse out the name & id in a returned JSON from a facebook API Graph call. The JSON return looks like this from Facebook:
{
"data": [
{
"name": "David xxxxxx",
"id": "05121212",
"administrator": true
},
{
"name": "Billy xxxxxxx",
"id": "0005128888"
}
],
"paging": {
"next": "https://graph.facebook.com/xxxxx/members?format=json&limit=5000&offset=5000&__after_id=xxxxx"
}
}
Any examples on how to go about parsing out just the name and id from the JSON response in ASP.net would be awesome!
Thanks,
David
Go for, http://james.newtonking.com/
string response = <your fb data>; // I am lazy :P
JObject obj = JObject.Parse(response);
JArray data = (JArray)obj["data"];
for(int i=0,int len=data.count; i < len ; i++)
{
string name = data[i]["name"].ToString();
string id = data[i]["id"].ToString();
string administrator = string.Empty;
if(data[i]["administrator"]!=null)
{
string administrator = data[i]["administrator"].ToString();
}
}
I think, this code is enough to get you going.
Always check for null as api data may or may not have that value.
Edit: I noticed that you wanted a VB code, sorry. But it may help others, so leaving it here. You can convert the code from any C# to VB convertor.
Regardless of whether or not there is a known library for .NET and Open Graph, Json is Json. The way I see it you have three options:
1) Use Newtonsoft Json. You can install this package using nuget into your ASP.NET project and from there there are lots of places on the web that talk about working with this library. http://james.newtonking.com/ is the home page of the library, there are also posts here.
2) Use .NET Json. Again, lots of info on the web here. I found a pretty good looking post here Parse JSON in C#
3) Use the C# Facebook SDK. The FacebookClient class has the ability to serialize and de-serialize Json. You can also install this library via Nuget. I admit the documentation on the C# SDK is lacking, but none the less it works well. More information about it can be found here: http://blog.prabir.me/category/Facebook-C-SDK.aspx
I hope this helps you down the right path.
-Eric
There are no known supported libraries for .net for the new graph api. https://github.com/facebook-csharp-sdk has a few samples for using .net though.

MVC2 - Consume RSS feed with RDF and namespace http://www.w3.org/1999/02/22-rdf-syntax-ns#'

I' trying to read the feed for the Washington Departmene of Fish and Wildlife, and keep etting this error:
The element with name 'RDF' and
namespace
'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
is not an allowed feed format.
Here's the code from RssController:
public virtual ActionResult Index()
{
string feedUrl = #"http://wdfw.wa.gov/news/newsrss.php";
using (XmlReader reader = XmlReader.Create(feedUrl))
{
**SyndicationFeed rss = SyndicationFeed.Load(reader);**
return View(rss);
}
}
I've done seveal RSS applications but nave never ran into this issue. Anyone got any concrete ways of being able to parse this in ASP.NET MVC 2? (the lines with asterics are where the exception happens.
There's no support for RSS 1.0. Example of how to roll your own support here : https://web.archive.org/web/20211020140320/https://www.4guysfromrolla.com/articles/031809-1.aspx
This may not be applicable to you as it sounds like you are only interested in RSS, but if you want RDF support for your application (RSS 1.0 uses RDF/XML to encode it's data) then you could try my library dotNetRDF.
I suspect that a full blown RDF API is probably overkill though judging from your question.

Resources