C# to get facebook status - c#

Simply put: I would like my application to go off and give me the latest facebook status update(or two) for a single user(me). IE: My website blah.com will display my own status update(with a like button if possible).
Added Complexity: I have read the following api http://developers.facebook.com/docs/reference/api/ {https://graph.facebook.com/[your facebook id]/feed} with little success of retrieving my status, unless i turn off my privacy settings. I would like to leave these as is for my test application as I don't think i can tell the client to make theirs public.
Where are we now: That leaves setting up with OAuth or using a 3rd party wrapper. I have had little success with the latter and am not skilled enough to set up with oauth.
Your help would be appreciated.

I just uploaded some source to github if you are interested. It's a little project to help with Facebook's Graph API. Feel free to check it out here. Its not the most scalable code, but it does the trick.

Why not grab it via RSS? Go here:
http://www.facebook.com/notifications.php
and click on the 'Via RSS' link to go to your notifications feed, and simply change 'notifications.php' in the URL to 'status.php'.
You should then be able to grab this feed in to an XmlDocument and check out the first item node.

Related

How to retrieve user names of commenters on an Instagram post

I have set a session cookie and can make a request to:
https://www.instagram.com/{username}/?__a=1 to get a list of the media ids (shortcodes).
I can then navigate to https://www.instagram.com/p/{shortcode}/ to view the media. However, I can't view the page source as it is populated by some JavaScript execution.
Is there a way to either view the page source after JavaScript execution, or another way to obtain the usernames of people who have commented?
Thank you
You can use the tool Swagger-Codegen to generate APIs for a bunch of websites.
Haven't tried with IG but a quick search on google gave me this:
https://app.swaggerhub.com/apis/saketthakare/instagram/1.0.0
You can use Export -> Client SDK -> your programming language to generate a client API.
EDIT: This might also interest you: https://developers.facebook.com/docs/instagram-basic-display-api

How to get a developer key for ViaGogo API

Long shot, but I'd like to fiddle with ViaGogo API (C# library more precisely). ViaGogo has a well documented public API, documentation is avaliable here.
Problem is, you need to authenticated as it usually happens with this kind of APIs: usually, you find a section of the website, maybe in your profile section, where you can obtain keys, secrets and so on (this happens for example on Facebook or Amazon).
As for ViaGogo, I only found a link that points to a Google Form: this form asks for info about advertising and affiliation on a complete different level of what I need, I won't publish anything read via API. Furthermore, there's no field to leave an e-mail address.
Their C# library seems pretty popular as far as I can tell from downloads from NuGet; I wonder how all these thousands of devs succesfully called that API.
Has anyone succesfully obtained authentication info from ViaGogo?
According to note in registration form, you have to wait for 30 days for their reply.
For more help you can contact them on following contacts:
E-mail: affiliate#viagogo.com
Telephone: +442075532777
Or
http://www.viagogo.com/in/help
There doesn't seem to be any way around this registration according to their website and the api itself -- an appID and password is required. You may try your luck emailing them at Affiliate.Team#viagogo.com -- see this issue on github where the possibility of getting an account via email is discussed: https://github.com/viagogo/developer.viagogo.net/issues/24

Is there a way to customize the Thinktecture.IdentityServer.v2 login page?

I'm using the Thinktecture.IdentityServer.v2 app to perform SSO for a couple of internal apps but would like to customize the login page for each application to have a smoother user experience. I can't seem to find a way to do that.
Can the login page be customized depending on the source application from where the client is comming?
"I can't seem to find a way to do that." - How hard have you tried? ;)
The RP has the extra data fields - so you can hang like a CSS name off the RP in the registration database. Further you can get to that RP data from the signin page - quoting the comment in AccountController:
// you can call AuthenticationHelper.GetRelyingPartyDetailsFromReturnUrl to get more information about the requested relying party
btw - IdentityServer's github repo has an issue tracker - you should use that for questions.
You can always have the RP pass a custom query string param and customize off of that. But you're outside the bounds of WS-Federation at that point. Plus, you must think about the nature of SSO -- the user is really signing into the IdP, not the app. So changing the IdP to look like the app is somewhat disingenuous.
I have solved this by customizing the SignIn.cshtml to adjust the style to what I need. Additionally, I have server side code in the top of SignIn.cshtml that does some string matching on the ReturnUrl (Request.QueryString["ReturnUrl"]). Then I show a different logo and header text based on some values I know to be unique for the different RP urls.
When upgrading to a new version of the ThinkTecture MVC, it will be a small job to update only this file to your specifics (just remember to have a copy of your modified SignIn.cshtml before you upgrade).

Twitter Streaming API C#

Hi does anyone know how to use the streaming API for C#? Therefore, whenever there is a new tweet in my account, it will be reflected in my program.
So far the only reliable wrapper I've found for this in .Net land is TweetInvi. Try to ignore that the web site looks like it was designed by a hyperactive 10-year old (thanks MS 'metro' team), the actual library is very well designed and rock solid.
Assuming of course you have the relevant access tokens (if not see http://dev.twitter.com), an example of how easy it is to have up and running:
TwitterCredentials.SetCredentials(userToken,userTokenPrivate,apiKey,apiKeyPrivate);
_userStream = Stream.CreateUserStream();
_userStream.TweetCreatedByFriend += (sender,args) => Console.WriteLine(args.Tweet.Text);
_userStream.Start();
This will write the body of tweets to your console output, and it updates even faster than leaving the actual Twitter web site open. There are other events exposed for when a tweet is favourited, retweeted, when you have a new follower etc.
I can vouch for this library as being reliable - I am using it for my CovertTweeter project and have had absolutely no issues with it. In fact accessing the streaming API through TweetInvi has been even easier than the many brick walls I was left hitting when using REST wrappers like Linq2Twitter and TweetSharp.
Have a look at this post:
Streaming with New .NET HttpClient and HttpCompletionOption.ResponseHeadersRead
You don't have the complete implementation there but you will get the idea.
Here is a sample which "Reads data from the Twitter Streaming API and adds it to MSMQ. A second process (included) reads from the queue, parses the json message, and updates a data store."
https://github.com/swhitley/TwitterStreamClient
You can change the above problem to generate an event when it updates the data store. In your program you can subscribe this event to do whatever you want.
If you are looking for OAuth based sample then please use "AuthPack" which Provides .NET oAuth for Twitter, Facebook, LinkedIn, and Google:
https://github.com/swhitley/AuthPack/tree/master/AuthPack
I have found a good sample code that uses streaming API, here Twitterizer.

What can I use in Place of URL Referrer check to know where the request is coming from on my domain?

I have to implement a single signon kind of solution on my website. Let's say my website is www.myweb.com and I want to allow the users to use this site who only come from a site www.sourceweb.com.
I thought URL Referrer would do but in IE may comes null.
See here
Please suggest me some alternate solution.
Thanks,
Gaurav
If you have access to www.sourceweb.com and can modify the source then a possible solution would be:
Create a webservice on www.myweb.com.
Create a link on www.sourceweb.com
When the link is clicked call the webservice to retrieve a unique id.
Redirect the user to www.myweb.com and provide the unique id in the querystring.
On www.myweb.com confirm that the unique id is valid and remove it/mark it as used.
There are many ways to skin a cat, one way in your case would be to set a cookie on the 2nd site, using a pixel gif (1x1 pixel small picture) embedded on a page of the main site. The 2nd site then can later allow access only when the cookie is already set.
To make this secure, you have to add a token to the pixel gif URL, containing a timestamp and signed using a HMAC or something similar establishing a shared secret with the other site. Then you only set the cookie when the timestamp is recent (less than a minute ago) and properly signed.
URL_REFERER is your best bet.
Keep in mind that like most HTTP headers, it is easy to forge and does not have to be provided.
The very short answer. Don't implement this yourself.
Security solutions should not be implemented but bought. The only exception being if you actually develops security solutions for other to buy of course.
Choose one of many available SSO solutions and go with that. We use Microsofts ADFS, though not perfect it gets the job done for us with very little maintance and the only real hazle is for our applications hosted on non-windows platforms like AIX.
There so many chance of screwing things up when you try to implement your own security solutions. If you disagree than just remember than anual contests are held to break the security systems of companies such as Apple,Microsoft,Mozilla and Goggle and most of the years some one takes home the price for breaking each of them.

Categories

Resources