Currently have no experience in programming and have been chucked in the deep end. I've currently made a simple UWP app that has a text box and a button. I want it so when I type in the text box and hit the button, the content from that text box is stored into a onedrive account as a text file. currently I have thee layout done and I've double clicked the button to enter the cose but I don't know what else to do and I havent had much luck with googling around. Any help or solutions? Thanks!
We can use OneDrive API to do this in UWP apps. This is a modern REST API and based on this API there are some OneDrive SDKs for different platforms to quickly start using the OneDrive API without the need to get into all the details of authentication, JSON parsing, HTTP connections and more. As you are using C#, OneDrive SDK for C# is strongly recommended.
For more info about how to use this SDK in UWP apps, please see Getting started and Documentation and resources on GitHub and also the article: Windows 10 - Implementing a UWP App with the Official OneDrive SDK.
Following is a simple sample. In the sample, I used OneDrive's App Folder, this folder is a dedicated, special folder for your app. It is typically named after your app, and is found in the Apps folder in the user's OneDrive. If you request the onedrive.appfolder permission scope and the user authorizes it, your app gets read and write access to this folder.
private async void Button_Click(object sender, RoutedEventArgs e)
{
var oneDriveClient = await OneDriveClientExtensions.GetAuthenticatedUniversalClient(new[] { "onedrive.appfolder" });
using (var contentStream = new MemoryStream(Encoding.UTF8.GetBytes(textBox.Text)))
{
var item = await oneDriveClient.Drive.Special.AppRoot.ItemWithPath("backup.txt").Content.Request().PutAsync<Item>(contentStream);
}
}
Related
I created a Chatbot (Microsoft Botframework) with a Cortana Skill where i am trying to prompt the user to upload an attachment.
The prompt is asking the user to upload the file as specified (Code below) but i do not see a possibility of uploading files in Cortana. Is there a way to make this work? Thanks a lot!
var dialog = new PromptDialog.PromptAttachment("Please upload the sick
note you received from your doctor.", "Sorry, I didn't get the document.
Try again please.", 2);
context.Call(dialog,this.uploadAttachmentResumeAfter);
The Cortana Skills Kit does not presently support file uploads through Cortana. However, you can work around this by deep linking - add the capability to support a html form file upload in your app and follow the steps to invoke it in the mentioned doc.
Hope this helps.
I wonder how to open the official Facebook App for sharing an URI from my C# code on Windows Phone. The common Uri-Scheme like "fb://" may open the App but no parameter seems to work. I have something like this in mind, but it will not work for me:
LaunchUriAsync(new Uri("fb://publish/profile/me?text=foo"));
Of course I know that I could use the ShareTask but that's not what I want.
You can take a look at the Spotfy App, it does exactly, what I want to do, when sharing a song.
Thank you for your help and answers!
PS: Same with Twitter by the way...
I finally solved it!
It took me nearly two days to find the solution and it is not documented anywhere sothat I would like to share my results with you:
// Open official Facebook app for sharing
await Windows.System.Launcher.LaunchUriAsync(new Uri("fb:post?text=foo"));
I think this is a very cool feature and reminds users of how it works on other plarforms.
In conclusion launching other apps from your app via URI schemes is always a great scenario with a nice user experience.
Hint: Opening the official Facebook App via URI schemes requires at least version 4.1!
If you wanna share the link, you can use ShareLinkTask
ShareLinkTask shareLinkTask = new ShareLinkTask();
shareLinkTask.Title = "My Title";
shareLinkTask.LinkUri = new Uri("http://fb.me/profile.php", UriKind.Absolute);
shareLinkTask.Message = "Yep. I can share a link on facebook.";
shareLinkTask.Show();
When user calls this method, it will show the sharable social networking apps installed on the phone, so you can share a link on the facebook, twitter & etc (if installed)
If you wanna share the local media file, you can use ShareMediaTask
I'm sorry if this subject has already been answered, but I couldn't find what I needed (yet).
I'm working on a program that downloads files from university websites that use the same infrastructure. It's an open source project which I'm trying to support in my free time
(hosted in goodle code: http://code.google.com/p/highlearner/)
Until now we used GET and POST requests to login into the right page and download stuff. But the universities keep changing their websites and every little change requires teaking in Highlearner, which requires a new version, auto-updating all users, etc. Also, every university has its own login page, requiring me to tailor a login sequences..
So I'm looking for a more robust solution. Instead of manually redirecting and setting the HTTP parameters. Is there some kind of mini browser that supports with HTML + Javascript? No GUI is needed, I just need the engine.
This way, I will simply need to fill out the form parameters and let the browser do the work.
Thanks,
Nitay
You could try to automate the process with WatiN library . It allows you to click buttons, submit forms, etc.
using (var ie = new IE(loginUrl))
{
if (ie.TextField("username").Exists
&& ie.TextField("password").Exists)
{
ie.TextField("username").Value = "username";
ie.TextField("password").Value = "password";
ie.Button(Find.ByName("submit")).Click();
}
}
I hope the question is self-describing.
I'm currently developing an asp.net website which uses a MS SqlServer database in the data layer.
And I was thinking what are my options to get a mobile version (most importantly supports BlackBerry and iPhone and hopefully every mobile device!) and when used on blackberry I want to be able to let it run at the BB's background.
I was thinking about asp.net mobile controls but the projects page seems like a dead/not-updated framework and not sure exactly if supports only windows mobiles or what!
Edit
Thank you for your questions, but they all covered my problem from only one respective .. I mean how this is going to let me use the BlackBerry Appliction options like letting my website run at the device background or sending notifications to my users!
This is mostly going to be a product of styling. Mobile websites work just like regular websites these days, except you want to use CSS and images that work well on a mobile device. You can use a product like 51 Degrees that will give you a bunch of information on what type of device is connected, so you can customize your output based on resolution or any number of other things if you so desire.
You could also try a book on mobile design, such as "Mobile Web Design" by Cameron Moll.
If you use ASP.Net MVC to create your app and create regular and mobile views. You can use jQuery Mobile to help with the mobile views too.
This question covers how to change your view based on the device type,
If you use WebForms, you can change your MasterPage depending on the browser thus giving you the ability to swap to mobile versions more easily:
protected void Page_PreInit(object sender, EventArgs e)
{
if (Request.Browser.IsMobileDevice)
MasterPageFile = "~/Mobile.Master";
}
Or use a Global.asax to redirect mobile requests completely:
void Session_Start(object sender, EventArgs e)
{
// Redirect mobile users to the mobile home page
HttpRequest httpRequest = HttpContext.Current.Request;
if (httpRequest.Browser.IsMobileDevice)
{
string path = httpRequest.Url.PathAndQuery;
bool isOnMobilePage = path.StartsWith("/Mobile/",
StringComparison.OrdinalIgnoreCase);
if (!isOnMobilePage)
{
string redirectTo = "~/Mobile/";
// Could also add special logic to redirect from certain
// recognized pages to the mobile equivalents of those
// pages (where they exist). For example,
// if (HttpContext.Current.Handler is UserRegistration)
// redirectTo = "~/Mobile/Register.aspx";
HttpContext.Current.Response.Redirect(redirectTo);
}
}
}
Either way read this article: http://www.asp.net/learn/whitepapers/add-mobile-pages-to-your-aspnet-web-forms-mvc-application
You don't really need to do anything special; Just create an alternative stylesheet that is optimized for 320px width viewport. You can serve this stylesheet through a separate stylesheet using the "media" attribute of the LINK element, or you can use CSS Media Queries within your mater stylesheet. Some relevant info:
http://googlewebmastercentral.blogspot.com/2011/02/making-websites-mobile-friendly.html
http://www.css3.info/preview/media-queries/
If you are using asp.net MVC be sure to check out
Web Application Toolkit for Mobile Web Applications
Currently I am using Codeplex's Facebook Developer Toolkit version 2 for my ASP.net Facebook application. I would like to be able to send notifications to a user's Inbox or wall of the application and was wondering what are the available functions to do that? If not in the API, then please provide example functions from the main Facebook library. This will help immensely. Thanks!
After a brief search I found an example of sending notifications using the toolkit:
facebook.Components.FacebookService fs
= new facebook.Components.FacebookService();
fs.ApplicationKey =
ConfigurationManager.AppSettings["APIKey"];
fs.Secret =
ConfigurationManager.AppSettings["Secret"];
string sessionKey =
dict["facebook_session_key"];
fs.SessionKey = sessionKey; fs.uid =
long.Parse(member.FacebookId);
fs.notifications.send(member.FacebookId,
"notification message");
(from: http://facebooktoolkit.codeplex.com/Thread/View.aspx?ThreadId=49876)
After looking through the Codeplex source it's clear that this sends a user-to-user notification, and therefore requires an active user session of the sender.
Codeplex does not appear to support app-to-user notifications which do not require a session, but adding this feature would be trivial. Add a type variable to the send method and set it accordingly based on the API documentation here: http://wiki.developers.facebook.com/index.php/Notifications.send
The source code for the notifications.send method in the Codeplex Developer Toolkit is here:
http://facebooktoolkit.codeplex.com/SourceControl/changeset/view/28656#233852
Please keep in mind that the Codeplex developer toolkit source code has not been updated in over 3 months. This means that it does not support many new Facebook API features and changes. You may want to browse the client library wiki page to find a library that is more up to date: http://wiki.developers.facebook.com/index.php/Client_Libraries