Tweetinvi - User.GetAuthenticatedUser is not being recognized by Visual Studio - tweetinvi

I am using Tweetinvi api in Visual Studio and trying to fetch my profile name and profile photo.I followed the documentation on git and was trying to replicate the same in my code ,however it is not recognizing the method GetAuthenticatedUser
var authenticateduser = User.GetAuthenticatedUser();
I have seen some questions like this that said ,you need to give your keys to the method below, however i am doing that and am able to post and fetch tweets
Auth.SetUserCredentials("key1",key2","key3,"key4")
This is my Pageload code
protected void Page_Load(object sender, EventArgs e)
{
Auth.SetUserCredentials("key1",key2","key3,"key4")
var authenticateduser = User.GetAuthenticatedUser();
FetchTweets();
}

i had imported Tweetinvi but somehow this particular function is not being picked up
so have to use code with
var authenticateduser = Tweetinvi.User.GetAuthenticatedUser();
LblProfileName.Text = authenticateduser.Name;
ImgProfile.ImageUrl = authenticateduser.ProfileImageUrl;

Related

How can I use the ItemHeaderTapped event of the devexpress.maui.controls tabview?

The goal is to load/reload data for a tab when it is selected.
However for some reason I can't get it to run.
The code in xaml file looks like this:
...
<dxco:TabView ItemHeaderTapped="LoadTab">
<dxco:TabViewItem HeaderText="Tab1">
...
</dxco:TabViewItem>
...
</dxco:TabView>
On the SampleViewModel file I tried this:
private void LoadTab(Object sender, ItemHeaderTappedEventArgs e)
{
...
}
I also tried EventArgs instead of ItemHeaderTappedEventArgs.
But in both cases I get the error:
"EventHandler 'LoadTab' with correct signature not found in type Project.View.SamplePage"
Documentation to this Event is found here:
https://docs.devexpress.com/MAUI/DevExpress.Maui.Controls.TabView.ItemHeaderTapped
What am I doing wrong? Any help appreciated as I could not find any further information using google.

Visual Studio project to call Azure ML Endpoint, namespace how-to

I have a Visual Studio WebForm C# project that loads in a browser. I also have a snippet of code from Azure ML to call my endpoint model. How should the *.aspx.cs file look? Thank you.
screen shot of my visual studio *.aspx.cs file
Here is how I plan to call it from the carprice.aspx file:
<asp:Label ID="lblResults" runat="server" Text="here is where results will go"></asp:Label>
Here is the Namespace template from Visual Studio project, the carprice.aspx.cs file:
namespace web13
{
public partial class carprice : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
And here is the snippet from Azure, a different kind of namespace syntax:
namespace CallRequestResponseService
{
class Program
{
static void Main(string[] args)
{
InvokeRequestResponseService().Wait();
}
static async Task InvokeRequestResponseService()
{
var handler = new HttpClientHandler()
{
ClientCertificateOptions = ClientCertificateOption.Manual,
ServerCertificateCustomValidationCallback =
(httpRequestMessage, cert, cetChain, policyErrors) => { return true; }
};
using (var client = new HttpClient(handler))
{
// Request data goes here
var scoreRequest = new
{
Inputs = new Dictionary<string, List<Dictionary<string, string>>>()
{
{
"input1",
new List<Dictionary<string, string>>()
{
new Dictionary<string, string>()
{
{
"price", "5800"
},
{
"year", "2013"......etc
The next day, I tried calling HTML label control from the Azure snippet of code, but I get an error, "the name lblResults2 does not exist in the current context." I've also tried changing the Azure snippet to Public classes. Here is another screen shot. thank you.
Visual Studio connecting Azure Results to form
Then further along, I'm adding newer screen shots
Visual Studio webform controls
Visual Studio namespace
further days along, this is what gets Visual Studio to compile and load in browser. screen shot is:
working syntax for calling endpoint

Unit testing "object reference not set to an instance " at NUnit

i have a ASP.Net project and Nunitasp framework work for unit testing,i have a object in account.aspx.cs file when i tried to test the object(NugetplatformModel) value i get"object reference not set to an instance" error,
my account page code is given below
public partial class Account : System.Web.UI.Page
{
public NugetPlatformModel NugetPlatformModels;
public string result = string.Empty;
protected void Page_Load(object sender, EventArgs e)
{
if (!WebSecurity.IsAuthenticated)
{
Response.Redirect("/login", true);
}
else
{
result = "success";
NugetPlatformModels = new NugetPlatformModel();
}
}
my test case code is given below
[Test]
public void AccountPage_ValidCredential_AccessModel()
{
Browser.GetPage(domain + "account");
string ExpectedPage = domain + "account";
logon();
Account acccountPage = new Account();
AssertEquals("success", acccountPage.result);
AssertEquals("should have license",true,acccountPage.NugetPlatformModels.IsHavingLicense);
}
How can I access and test that code behind variables? when start the testing the NUgetplatformmodel has been assigned i have checked it by debugging but after that in nunit gui it displays null reference error, i thought there is a problem in accessing variable in testcase..please help me..
It seems your code is not complete. From what I see here your account needs to run Page_Load in order to fill result and NugetPlatformModels. But I do not see how this method is launched in your test. Is it run from the constructor of Account?
It would be helpfull if you put all the code for Account in your post.

Facebook with DotNetOpenAuth 4.1.0.12182

I'm attempting to create a user login for Facebook and Windows LiveId using DotNetOpenAuth 4.1.0.12182
However the examples in the download make use of DotNetOpenAuth.ApplicationBlock and DotNetOpenAuth.ApplicationBlock.Facebook which don't exist in the current build.
Instead there is the DotNetOpenAuth.AspNet.Clients namespace which includes FacebookClient and WindowsLiveClient - however I can't find any example of how to use these.
Do any examples or documentation exist?
I have been able to get DNOA version 4.1.0.12182, .Net 3.5 and Facebook to work with each other by creating a FacebookAuthClient that is derived off of the DotNetOpenAuth.OAuth2.WebServerClient. One little gotcha that I have found is that if you are using cookie based sessions then you have to access the session before you use the OAuth functionality. From what I can tell this is because DNOA uses the Session ID as the state parameter and if session has never been accessed it can change between requests. This will cause a state parameter mismatch error when the response comes back from Facebook.
FacebookAuthClient:
public class FacebookAuthClient : DotNetOpenAuth.OAuth2.WebServerClient
{
private static readonly DotNetOpenAuth.OAuth2.AuthorizationServerDescription Description = new DotNetOpenAuth.OAuth2.AuthorizationServerDescription
{
TokenEndpoint = new Uri("https://graph.facebook.com/oauth/access_token"),
AuthorzationEndpoint = new Uri("https://graph.facebook.com/oauth/authorize")
};
public static readonly string [] ScopeNeeded = { "publish_stream" };
public FacebookAuthClient()
: base(Description)
{
}
}
Facebook.aspx.cs:
public partial class FacebookPage : System.Web.UI.Page
{
private FacebookAuthClient _client = new FacebookAuthClient
{
ClientIdentifier = ConfigurationManager.AppSettings["FBClientId"], //The FB app's Id
ClientCredentialApplicator = DotNetOpenAuth.OAuth2.ClientCredentialApplicator.PostParameter(ConfigurationManager.AppSettings["FBClientSecret"]) // The FB app's secret
}
protected void Page_Load(object sender, EventArgs e)
{
DotNetOpenAuth.OAuth2.IAuthorizationState auth = _client.ProcessUserAuthorization();
if (_auth == null)
{
// Kick off authorization request with the required scope info
client.RequestUserAuthorization(FacebookAuthClient.ScopeNeeded);
}
}
}
This is just a test app so there is no error handling but it seems to work.
Edit
I used the DotNetOpenAuth(unified) NuGet package for all of this.
Edit
Added missing .PostParameter call to the creating of the ClientCredentialApplicator.
You'll need to use ctp version 3.5 of DNOA. Version 4+ has been made to work with a later draft of OAuth 2 then Facebook uses.
You can find it on the owners GitHub:
https://github.com/AArnott/dotnetopenid

Is there a standard dialog for constructing an ADO.Net connection string (that is redistributable)?

I want to use a standard dialog to solicit user input of an ADO.net connection string. It is trivial to do for the oledb connection string as described here:
MSDN Article on MSDASC.DataLinks().Prompt
I've also found examples that use Microsoft.Data.ConnectionUI.dll and MicrosoftData.ConnectionUI.Dialog.dll from VS (HOWTO: Using the Choose Data Source dialog of Visual Studio 2005 from your own code).
Unfortunately these DLLs are not licensed for redistribution.
Is there a standard dialog for choosing a data source that can be distributed with my application?
#rathkopf, it looks like these DLLs have been authorized for redistribution since Feb 2010:
http://connect.microsoft.com/VisualStudio/feedback/details/423104/redistributable-microsoft-data-connectionui-dll-and-microsoft-data-connectionui-dialog-dll
http://code.msdn.microsoft.com/Connection
The source code for these DLLs is now available: http://blogs.msdn.com/b/vsdata/archive/2010/02/02/data-connection-dialog-source-code-is-released-on-code-gallery.aspx
Also you can do this programmatically using the DataLink Properties:
Add the reference to ADODB.DLL (from .NET reference) and Microsoft OLE DB Service Component 1.0 Type Library from the COM tab in your visual studio reference tab.
using ADODB;
using Microsoft.Win32;
public partial class ConnectionStringStep : Form
{
private const string MSSQL_PROVIDER = "Provider=SQLOLEDB.1";
private const string ORACLE_PROVIDER = "Provider=MSDAORA.1";
private const string MSSQL = "MSSQL";
public ConnectionStringStep()
{
InitializeComponent();
}
private static string DataBaseType()
{
//get the data from some previous screen or some kind of storage
return MyStorage.GetProperty("DATABASE_TYPE") ?? "MSSQL";
}
private void button1_Click(object sender, EventArgs e)
{
var dataBaseType = DataBaseType();
var adodbConnection = new Connection
{
ConnectionString = dataBaseType == MSSQL ? MSSQL_PROVIDER : ORACLE_PROVIDER
};
object connection = (object) adodbConnection;
var dialog = new MSDASC.DataLinks();
dialog.PromptEdit(ref connection);
connectionTextBox.Text = adodbConnection.ConnectionString;
}
}
DataLink Properties Reference
There is now a NuGet package by Microsoft providing this dialog:
DataConnectionDialog.
Sample usage:
var dialog = new DataConnectionDialog();
dialog.DataSources.Add(DataSource.SqlDataSource);
dialog.ConnectionString = connectionString;
if (DataConnectionDialog.Show(dialog) == System.Windows.Forms.DialogResult.OK)
{
connectionString = dialog.ConnectionString;
}
It's related, but I'm now sure how you can embed this behavior inside your application.
Every time I need one, I create an empty text file, changed its file extension to ".udl" and double-click it; when I'm done, I close that application, rename that file back to ".txt" and open with Notepad.
It appears that such a beast does not exist. I've written my own dialog and can include it in projects as needed.
Update:
The source code for these DLLs are now available as per #code4life's answer.