Facebook UI call in ASP.NET MVC does not return the picture it should - asp.net-mvc

Does anyone know why the picture attribute is not working in following Facebook UI call?
function postToWallUsingFBUi()
{
var data=
{
method: 'stream.publish',
message: "Posted using FB.ui and picture.",
display: 'iframe',
caption: "Caption",
name: "Name",
//ver 1 picture: 'http://www.somedomain.com/albums/s339/rockaja/fb-520.png',
//ver 2 picture: '#Url.Action("Action", "Controller", new { PageId = Model.PageTabId }, Request.Url.Scheme)',
picture: 'https://localhost/MyVirtualDirectory/Controller/Action/283659015078395',
link: "http://www.mydomain.com/", // Go here if user click the picture
description: "Description field",
actions: [{ name: 'action_links text!', link: 'http://www.mydomain.com' }]
}
FB.ui(data, onPostToWallCompleted);
}
As you can see the picture attribute uses a picture from localhost. If i paste this URL into the browsers's Address field, i get the picture as expected.
I also commented out other two versions:
version 1 is working properly as expected, but
version 2 is not working (this is an ASP.NET MVC call, but that fact does not affect the result).
May be it is due to the fact that i request a localhost-ed picture?!

I have never worked on FB API so take my suggestion with a pinch of salt.
Based on my understanding of how Facebook works, whatever pictures you share on user's wall go into FB's data store first and are always pulled from that store.
Here, The Facebook API may be downloading the picture from the URL you have provided and push it into it's own store before publishing it on user's walls. When you use a localhost url, then the call to download the picture would obviously fail.
There must be another version of the API where you should be able to send the picture content as byte array. If there is, then you can load the picture from disk yourself and send the byte array in the API

Related

Passing report level filter to power bi from asp.net mvc application

I have embedded power bi report in my asp.net mvc application. It is working fine and it is showing data. I am having one issue, in my application every client has few branches like cities. Every user for that client may have access to all or some branches and based on that access we show data when that user is logged into system.
I want to achieve same in power bi that when user is logged into system and view reports it should show him/her data of branch he/she has access to. I found one solution
[Can I pass a dynamic query parameter to an embedded Power BI report in ASP.Net MVC? where we can set filter values from program side. I applied this in my view but i am still getting all data.
const branchFilter = {
$schema: "http://powerbi.com/product/schema#basic",
target: {
table: "tblWorkhistory",
column: "BranchID"
},
operator: "In",
values: [1],
filterType: models.FilterType.BasicFilter
}
var config = {
type: 'report',
tokenType: models.TokenType.Embed,
accessToken: accessToken,
embedUrl: embedUrl,
id: embedReportId,
permissions: models.Permissions.All,
viewMode: models.ViewMode.View,
filters: [branchFilter],
settings: {
filterPaneEnabled: true,
navContentPaneEnabled: true
}
};
Here i want to apply filter where it will show data for only branch whose id is 1 but it is showing all data. Am i missing anything here? do i need to do anything report side also after this code?
Regards,
Savan
Applying filter using embed config is supported, and the code sample you've shared seems valid.
If report.setFilters fails as well, seems like something with the filter is wrong.
Try to verify the data type of the filter, should it be 1 or "1"?
If this doesn't work, is there any error message being returned from .setFilters request?:
const filter = { ... };
report.setFilters([filter])
.catch(errors => {
// Handle error
});
Learn more here about setting filters through JS SDK.
To show data based on the user logged into you application you have to apply Row Level Security (RLS) in your power bi report first and then follow the steps from following article https://learn.microsoft.com/en-us/power-bi/developer/embedded-row-level-security

Allow access after sharing url

On a MVC 5 web site I would like visitors to be able to read the full version of a post only after they shared it on Facebook or Twitter.
I have seen this example in a few web sites ... What would be the best way to do this?
There is no real security issues here ... It is just a way to spread the word ...
My first idea would be to save a cookie with a post KEY (Guid) ... This key is not visible to the user so he will not know the value.
The problem is how do I know that he shared the url ... How do I get the confirmation?
Thank You,
Miguel
You get confirmation as follows, per the Facebook Developers Docs:
FB.ui(
{
method: 'feed',
name: 'Facebook Dialogs',
link: 'https://developers.facebook.com/docs/dialogs/',
picture: 'http://fbrell.com/f8.jpg',
caption: 'Reference Documentation',
description: 'Dialogs provide a simple, consistent interface for applications to interface with users.'
},
function(response) {
if (response && response.post_id) {
alert('Post was shared.'); //give access to article
} else {
alert('Post was not shared.'); //they chose not share... don't give access
}
});
I implemented this code almost verbatim in a .NET project (just replaced the alerts with my own functionality) where I gave users two entries into a contest if they shared the contest page (instead of one entry if they didn't share or did nothing).
As for Twitter, I've personally not implemented something similar, but your best bet is probably JavaScript Interfaces for Twitter for Websites.
I don't know about Facebook, but with Twitter a retweet is the same as a share. The statuses/retweeters/ids should work. If you have the id of the tweet, then you can hold a list of who retweeted it, updating as needed to get new ids.
https://dev.twitter.com/docs/api/1.1/get/statuses/retweeters/ids
If you don't want to write all of the code to authenticate and configure the endpoint, you could use a 3rd party library. Here's an example from my library, LINQ to Twitter v3.0 Beta:
ulong tweetID = 210591841312190464;
var status =
await
(from tweet in twitterCtx.Status
where tweet.Type == StatusType.Retweeters &&
tweet.ID == tweetID
select tweet)
.SingleOrDefaultAsync();
if (status != null && status.User != null)
status.Users.ForEach(
userID => Console.WriteLine("User ID: " + userID));
BTW, there's also a Facebook SDK for .NET.

Finding Facebook ID from URL

In Facebook's documentation it says you can find the ID from a URL, and that used to be the case. It doesn't appear to be true anymore.
This example is straight from Facebook's API Documentation:
--------------FACEBOOK DOCS---------------------
The "ids" query parameter also accepts URLs. This is useful for finding IDs of URLs in the Open Graph. For example: https://graph.facebook.com/?ids=http://www.imdb.com/title/tt0117500/
But when you click on that link it gives you:
{
"http://www.imdb.com/title/tt0117500/": {
"id": "http://www.imdb.com/title/tt0117500/",
"shares": 18226,
"comments": 7
}
}
Which does NOT include the real Facebook ID for this example URL. If I go to the debugger and enter this URL I can find the ID, which is: 380728101301
So how can I find the ID without using the Open Graph Debugger? I need to be able to get IDs through the code on my site, and can't manually visit the debugger every time.. anyone know how to do this now?
Thanks very much!
There is one possibility with FQL:
SELECT url,site,id FROM object_url WHERE url = 'http://www.imdb.com/title/tt0117500';
https://developers.facebook.com/docs/reference/fql/

Facebook Private Message in Titanium

I am trying to send Facebook Private in my Titanium Application.I have tried in following two ways but i didn't get any success.
Method 1:
var data = {
link: "https://developer.mozilla.org/en/JavaScript",
name: "Best online Javascript reference",
message: "Use Mozilla's online Javascript reference",
test: [ {foo:'Encoding test', bar:'Durp durp'}, 'test' ]
};
var friendFbId = "xxx"
var path = friendFbId+"/feed"
Titanium.Facebook.requestWithGraphPath(path, 'POST', data, showRequestResult);
It is works fine but it is posted in my friend's timeline. But I need a private message(should be visible to my friend only).
Method 2:
var data1 = {
link: "https://developer.mozilla.org/en/JavaScript",
name: "Best online Javascript reference"
};
Titanium.Facebook.dialog("send", data1, showRequestResult);
I am getting folowing error
error_code=3&error_msg=This+method+is+not+supported+for+this+display+type
Any one help me to solve this issue. I am using Titanium 1.7.5 and ios. Thanks in Advance
According to Facebook the send dialog is currently not supported on mobile devices:
https://developers.facebook.com/docs/reference/dialogs/send/
The API doesn't allow for private messages, the closest you'll get would be to use the send dialog.
http://developers.facebook.com/blog/post/514/
https://developers.facebook.com/docs/reference/dialogs/send/
I'd suggest playing around with the different display parameter settings to see if one of them might work
http://developers.facebook.com/docs/reference/dialogs/#display
page
popup
iframe
touch
wap

Problems with sharing via LinkedIn a link with equal sign

I've encountered an issue with LinkedIn share API.
I am working on a iPhone project, testing my application on iOS 4.0, 5.0.
I used this project as an example:
[https://github.com/synedra/LinkedIn-OAuth-Sample-Client][1]
I thought I am a genius after successfully implementing this API not only for sharing an update, but also with following format(like shown in [https://developer.linkedin.com/documents/share-api][1]):
<?xml version="1.0" encoding="UTF-8"?>
<share>
<comment>83% of employers will use social media to hire: 78% LinkedIn, 55% Facebook, 45% Twitter [SF Biz Times] http://bit.ly/cCpeOD</comment>
<content>
<title>Survey: Social networks top hiring tool - San Francisco Business Times</title>
<submitted-url>http://sanfrancisco.bizjournals.com/sanfrancisco/stories/2010/06/28/daily34.html</submitted-url>
<submitted-image-url>http://images.bizjournals.com/travel/cityscapes/thumbs/sm_sanfrancisco.jpg</submitted-image-url>
</content>
<visibility>
<code>anyone</code>
</visibility>
</share>
Following advices and examples, I was preparing a JSON string that i was using.
So, i got this:
{
"visibility":
{
"code":"anyone"
},
"comment":"Asd",
"content":
{
"submitted-url":"http://google.com",
"title":"googloo",
"submitted-image-url":"http://pikci.ru/images/img_srchttpwwwcomputerrivercomimagessamsung-chat-335-qwer.jpg"
}
}
Well, with this data inside, it works like a charm. the update is with image, clickable title and stuff. Perfect.
Then, i tried to put a link(because i really needed in purpose of my project) with a Equal sign in it: "=", like for example we have
http://www.google.md/#q=Nicolas+Steno&ct=steno12-hp&oi=ddle&bav=on.2,or.r_gc.r_pw.,cf.osb&fp=8c5a975d815425a&biw=1920&bih=881
Well, if we use this link in submitted-url, and send it, the LinkedIn will receive it, and even will give us a response. But it WONT update to the new status! It's a huge bug for my application, because the share won't work, but more than a half of the shared links will have equal sign in it. It is the third day when i'm fighting with it. I was trying different coding functions, different "smarty-pants" moves, but failed.
If anyone has a clue about what is going on here, I will hugely appreciate it...
When I post this body to LinkedIn I get my status updated:
{
"comment": "Posting from the API using JSON",
"content": {
"submitted-url":
"http://www.google.md/#q=Nicolas+Steno&ct=steno12-hp&oi=ddle&bav=on.2,or.r_gc.r_pw.,cf.osb&fp=8c5a975d815425a&biw=1920&bih=881"
}, "visibility": {
"code": "anyone"
}
}
However, the link itself doesn't resolve correctly. It's likely that something about that URL is tripping up our link shortener - we're working on fixing these issues but in the meantime you could use something like the Google URL shortener URL:
body = {"longUrl": article['articleContent']['resolvedUrl']}
resp,content = http.request("https://www.googleapis.com/urlshortener/v1/url?key=xxx","POST",body=simplejson.dumps(body),headers={"Content-Type":"application/json"})
googleresponse = simplejson.loads(content)
... and then share that to LinkedIn. I realize it's a suboptimal solution, but until the share function gets fixed to handle these URLs it should get you going.

Resources