So, what I would like to do is to programmatically create a link to share with my colleagues in an email message, which allows them to open a OneNote page directly in the App.
I was able to figure out that my link is going to be something like:
onenote://base-path ...
but I'm not getting how to build the base-path link,
I'm able to have all the necessary page details (I guess) from an API call.
can anybody please tell me how to build a link for opening a OneNote page directly in app?
Thanks
You can use the GET Pages endpoint in the REST API to retrieve information about a specific page. The response will include a links field which contains a URL that will open that page in the OneNote client (if its available).
Here is an example response:
{
...
"links": {
"oneNoteClientUrl": {
"href": "onenote:https:\/\/d.docs.live.net\/73dbaf9b7e5c4b4c\/Documents\/James's%20Notebook\/PCR.one#PCR%20Test%20Page\u00ac\u00dfion-id=3dcda1be-9e78-aa4c-b97d-9cdbe9e5cfab&page-id=57197857-14bc-fd48-b2e7-16c2dbce94ee&end"
},
"oneNoteWebUrl": {
"href": "https:\/\/onedrive.live.com\/redir.aspx?cid=73dbaf9b7e5c4b4c&page=edit&resid=61528580FB755FBB!107&wd=target%28PCR.one%7C3dcda1be-9e78-aa4c-b97d-9cdbe9e5cfab%2FPCR%20Test%20Page%7C57197857-16bc-fd48-b2e7-26c2dbce94ee%2F%29"
}
}
...
}
This example was taken from: https://dev.onenote.com/docs#/reference/get-pages/v10menotespagesfilterorderbyselectexpandtopskipsearchcount/get
I hope this helps!
Related
I need to check weather the requested resource by user in browser is present in my asp.net website directory or not and if it is not present than redirect user to error page.
As I have removed a number of pages from my website and they already got indexed in google bot or sometimes typed by user directly in url.
so whenever request like this made from the browser, my code should do something like following;
if(requested url does not exist)
{
Response.Redirect("error.aspx");
}
how to achieve that programatically.
Thanks.
If i am not wrong this would be the solution you are looking for:
string URL ="mypage.aspx";
if (File.Exists(Server.MapPath(URL)))
{
Response.Redirect(URL,false);
}
else
{
Response.Redirect("~\\404PageNotFound.aspx", true);
}
I'm aware that data can be passed in through the URL, like "example.com/thing?id=1234", or it can be passed in through a form and a "submit" button, but neither of these methods will work for me.
I need to get a fairly large xml string/file. I need to parse it and get the data from it before I can even display my page.
How can I get this on page load? Does the client have to send a http request? Or submit the xml as a string to a hidden form?
Edit with background info:
I am creating a widget that will appear in my customer's application, embedded using C# WebBrowser control, but will be hosted on my server. The web app needs to pass some data (including a token for client validation) to my widget via xml, and this needs to be loaded in first thing when my widget starts up.
ASP.NET MVC 4 works great with jQuery and aJax posts. I have accomplished this goal many times by taking advantage of this.
jQuery:
$(document).ready(function() {
$.ajax({
type: "POST",
url: "/{controller}/{action}/",
data: { clientToken: '{token}', foo: 'bar',
success: function (data, text) {
//APPEND YOUR PAGE WITH YOUR PARSED XML DATA
//NOTE: 'data' WILL CONTAIN YOUR RETURNED RESULT
}
});
});
MVC Controller:
[HttpPost]
public JsonResult jqGetXML(string clientToken, string foo)
{
JsonResult jqResult = new JsonResult();
//GET YOUR XML DATA AND DO YOUR WORK
jqResult.Data = //WHATEVER YOU WANT TO RETURN;
return jqResult;
}
Note: This example returns Json data (easier to work with IMO), not XML. It also assumes that the XML data is not coming from the client but is stored server-side.
EDIT: Here is a link to jQuery's Ajax documentation,
http://api.jquery.com/jQuery.ajax/
Assuming you're using ASP.NET, since you say it's generated by another page, just stick the XML in the Session state.
Another approach, not sure if it helps in your situation.
If you share the second level domain name on your two sites (i.e. .....sitename.com ) then another potential way to share data is you could have them assert a cookie at this 2nd level with the token and xml data in it. You'll then be provided with this cookie.
I've only done this to share authentication details, you need to share machine keys at a minimum to support this (assuming .Net here...).
You won't be able to automatically upload a file from the client to the server - at least not via a browser using html/js/httprequests. The browser simply will not allow this.
Imagine the security implications if browsers allowed you to silently upload a file from the clients local machine without their knowledge.
Sample solution:
Background process imports xml file and parses it. The background process knows it is for customer YYY and updates their information so it know the xml file has been processed.
A visitor goes to the customer's web application where the widget is embedded. In the markup of the widget the customer token has been added. This could be in JavaScript, Flash, iFrame, etc.
When the widget loads, it makes a request to you app which then checks to see if the file was parsed for the provided customer (YYY) if it has, then show the page/widget.
If the XML is being served via HTTP you can use Liqn to parse the data.
Ex.
public partial class Sample : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string url = "http://news.yahoo.com/rss/";
var el = XElement.Load(url).Elements("channel");
StringBuilder output = new StringBuilder();
foreach (var c in el.Elements())
{
switch (c.Name.LocalName.ToLower())
{
case "title":
output.Append(c.Value);
output.Append("<br />");
break;
}
}
this.Label1.Text = output.ToString();
}
}
It is not exactly clear what the application is and what kind of options you have, and what kind of control over web server you have.
If you are the owner of the web server/application your options are way wider. You can first send a file to web-server with HTTP POST or PUT, including a random token, and then use the same token for GET with token in the query string
or use other options, applicable to third party-owned websites
if you are trying to consume some auth api, learn more about it. since you are hosting web browser control, you have plenty of options to script it. including loading whatever form, setting textarea or hidden field text with your xml and then simulating a submit button click. you can then respond to any redirects and html responses.
you can also inject javascript inside the page that would send it to server with ajax request.
the choice heavily depends on the interaction model.
if you need better advice, it would be most helpful if you provided sample/simplified url/url pattern, form content, and sequence of events that is expected from you from code/api/sdk perspective. they are usually quite friendly.
There are limited number of ways to pass data between pages. Personally for this I would keep in session during the generating page and clear it when it is retrieved in the required page.
If it is generated server side then there is no reason to retrieve it from client side.
http://msdn.microsoft.com/en-us/library/6c3yckfw(v=vs.100).aspx
Create a webservice that your C# app can POST the XML to and get back HTML in response. Load this HTML string into the WebBrowser control rather than pointing the control to a URL.
I am building an application where users will upload photos which will be stored in an album on their Facebook account. Currently, I am using the C# SDK to achieve this, and I managed to get the photo uploaded.
When I tried to query the photo using the following FQL in the Graph API explorer:
select object_id, like_info from photo where object_id=[my_object_id]
I get the following result:
{
"data": [
{
"object_id": "11111111111111111",
"like_info": {
"can_like": false,
"like_count": 0,
"user_likes": false
}
}
]
}
Uploading a photo by posting directly to the Graph API endpoint https://graph.facebook.com/me/photos?access_token=[my_access_token] and doing a FQL on the resulting ID gives the same result - the can_like has a value of false. On both occasions, the "Who can see posts this app makes for you on your Facebook timeline?" setting for the app was set to "Public".
If I view the photo page, I can see the photo but there are no "Like" or "Comment" buttons. Upon further investigation, I found that the "Like" and "Commment" buttons will only appear if I (or rather my access token's user) is a friend of the uploader. Is it possible to make the uploaded photo "Likeable"? My objective is to allow users who come to my app to be able to "Like" the individual photos without having to be a friend of the person who uploaded it. Can this be achieved or am I missing something? Thanks.
This is restriction of facebook, but i have found a workaround, when user have their subscriptions enabled here: https://www.facebook.com/about/subscribe anyone can like/comment their photos...
The problem is that 1) Facebook seems so fluid with how it allows developers to interact with it (FBML, iFrame, different versions of SDKs) and 2) Everything I find is either PHP or Javascript and I have NO experience with those. What I am trying to do seems sooo simple, and I can't believe there isn't an easy way to do this.
What I have:
I used Visual Studio 2010 to create a simple web application (asp.net/C#) that asks the user for some info (first name, last name, email, etc.). I have a button on there called "Submit" that, when clicked, saves the entered data into a database. I have this hosted on GoDaddy (I know, I know...heh) and it works just fine. No problem here.
I created a "Facebook App" that uses the iFrame thingy so that basically I have a new tab on Facebook that displays my web app mentioned above. This works fine too. The tab is there, the web app is there, and users can enter the data and it is saved to the database. No problem here.
What I WANT:
I want the web app (the thing displayed by the facebook app) to only show the data entry part if the user currently "likes" the facebook entity. I DO NOT want to have to ask permission. I just want to know if they are a fan of the company's facebook "page" that has this app. So I need two things here, shown in my pseudo code below:
Part 1 (check if user is already a fan):
If (user is fan)
{
Show data entry area (unhide it)
}
else
{
Show "Click the like button to see more options"
}
Part 2 (listen for "like" event)
WhenLikeButtonPressed()
{
Show data entry area (unhide it)
}
I've seen stuff about "visible to connection", C# sdk, edge.create, etc. but I just can't make heads or tails of it. I don't mind putting in Javascript or PHP if someone could please give me exact, "Fan Gate for Dummies" steps. Please, I'm going crazy over here :-(
The key is is the signed_request that Facebook posts to your app when the user accesses the page. It contains the data on whether or not the user likes the page. You shouldn't need to worry about catching edge events on an actual tab FB page as it get's reloaded when the user likes/unlikes the page.
You'll need to decode the signed request with your app secret to get the like info. There are examples provided for PHP but I'm sure with a little google help you can find decode info for the signed_request for asp.net/c#.
Here's the php decode for reference:
function parse_signed_request($signed_request, $secret) {
list($encoded_sig, $payload) = explode('.', $signed_request, 2);
// decode the data
$sig = base64_url_decode($encoded_sig);
$data = json_decode(base64_url_decode($payload), true);
if (strtoupper($data['algorithm']) !== 'HMAC-SHA256') {
error_log('Unknown algorithm. Expected HMAC-SHA256');
return null;
}
// check sig
$expected_sig = hash_hmac('sha256', $payload, $secret, $raw = true);
if ($sig !== $expected_sig) {
error_log('Bad Signed JSON signature!');
return null;
}
return $data;
}
function base64_url_decode($input) {
return base64_decode(strtr($input, '-_', '+/'));
}
and the link https://developers.facebook.com/docs/authentication/signed_request/ the like info will be contained in the page variable
I'm trying to use the Facebook C# SDK to post to a Facebook page stream, but I'm failing miserably. This is what my code looks like:
var app = new Facebook.FacebookApp(_accessToken);
var parameters = new Dictionary<string, object>
{
{ "message" , promotionInfo.TagLine },
{ "name" , promotionInfo.Title },
{ "description" , promotionInfo.Description },
{ "picture" , promotionInfo.ImageUrl.ToString() },
{ "caption" , promotionInfo.TargetUrl.Host },
{ "link" , promotionInfo.TargetUrl.ToString() },
{ "type" , "link" }
};
var response = app.Post(_targetId + "/feed", parameters);
I've checked and I can see the request in Fiddler go through to Facebook, and I get an ID back - however, when I try and view that ID at http://graph.facebook.com/[parentid]_[postid]
I just get a page with "false" on it, and the post doesn't appear on the Facebook page itself either. If I just enter a random postid that doesn't exist, I get "Some of the aliases you requested do not exist" instead.
The accessToken is authorised to use publish_stream and offline access (generated using this url)
Any ideas what could be going wrong? Thanks
Update I should add, this works fine if I change the _targetId to "me" (ie posting directly to my own profile page)
I found the solution here: Which Facebook permissions allow for posting to a page wall (not profile wall)? which did the trick
This is just an idea, but try it after obtaining the read_stream extended permission.
I know from experience that you can use the ID returned to delete the post, but without read_stream I don't think you can retrieve it (and more interesting stuff like the comments)
To post to a Facebook page, You need to request manage_pages permission.
also you have to use the PAGE access_token not User access_token.