Facebook post on own steam not showing - c#

So I'm having trouble with updating the facebook status.
Using the following code:
private const string FacebookPermissions = "user_about_me,publish_stream,read_stream";
try
{
dynamic fbPostTaskResult = await fbclient.PostTaskAsync("/me/feed", new { message = "" + text });
var responseresult = (IDictionary<string, object>)fbPostTaskResult;
fbclient.PostCompleted += fbclient_PostCompleted;
failed = true;
}
catch (Exception e)
{
ObjFBHelper.LoginAndContinue();
}
The problem is that it's shared at all. Can only be viewed by me.
Have checked the facebook settings and it's set to friends.
Have anyone seen this before? Havent got any hits on google.

You need to flick the switch next to “Do you want to make this app and all its live features available to the general public?” on the Status&Review tab in your app dashboard to “Yes” …
Anything posted via an app will only be visible to the general public, if that is set. Otherwise only people with a role in the app (admin/developer/tester) will be able to see the created content.

You need to allow in settings to make it visible for other users.

Related

Logging in in embedded browser deprecation

Facebook is terminating logging in via embedded browser. I have implemented FB login using CustomRenderer in Xamarin.Forms.
In that we do not have option of LoginBehavior. So does anyone know how to handle this in Xamarin.Forms?
The best solution is to open the login page in a CustomTab, Android offers such tabs so one does not have to call an external browser (I don't know whether Xamarin offers its own classes to use OAuth).
public void OpenWebsiteInApp(string url)
{
// Use the Android custom tabs to display the webpage inside the app.
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
CustomTabsIntent customTabsIntent = builder.Build();
customTabsIntent.LaunchUrl(_applicationContext, Uri.Parse(url));
}
To catch the redirect from the online service, you need to implement an activity with an IntentFilter defining a DataScheme.
Finally I have got the solution for Xamarin.Forms. I have followed this tutorial and the problem is solved.
https://evgenyzborovsky.com/2018/03/09/using-native-facebook-login-button-in-xamarin-forms/
After successful login we are getting Access_token and userid values and by using it we can get user details like First name, Last name easily.
Here is the code for the same:
var client = new System.Net.Http.HttpClient();
var url = $"https://graph.facebook.com/{facebookResponse.userId}?
fields=id,first_name,last_name,email,picture&access_token=
{facebookResponse.accessToken}";
var response = await client.GetAsync(url);
var result = response.Content.ReadAsStringAsync().Result;
var resultobject = JsonConvert.DeserializeObject<FacebookResponse>(result);
Limitations:
You can not change Login button Icon or Text properties like font and size etc.
If you want to use another FB account to login you first have to logout from device's browser manually.

Spotify authorization code flow (WPF browser control) C#

I'm using Spotify account service (authorization code flow) to get an authorization code by passing in the required parameters (client_id, response_type and redirect_uri. Its a WPF application so i am using the browser control and navigating the user to
https://accounts.spotify.com/authorize/?client_id=myclientId&response_type=code&redirect_uri=someUri
When i copy paste the link in the browser, i see the right stuff i.e page with the Login to Spotify button but when i am navigating through the browser control in my WPF application, it gives me a file download dialog with Authorize.json file to download with Open and Save options, however in some cases it presents the right page to browser code.
Below is my code:
public winOAuthBrowserForm(string navigateTo)
{
InitializeComponent();
webBrowser.Navigated += webBrowser_Navigated;
webBrowser.Navigate(navigateTo);
}
private void webBrowser_Navigated(object sender, System.Windows.Navigation.NavigationEventArgs e)
{
if(!String.IsNullOrEmpty(e.Uri.Query))
{
//since we are looking for code for authorization that will be exchanged for request token from the server
if (e.Uri.Query.StartsWith("?code=") || e.Uri.Query.Contains("code="))
{
code = HttpUtility.ParseQueryString(e.Uri.Query).Get("code");
this.Close();
}
if (e.Uri.Query.StartsWith("?error=") || e.Uri.Query.Contains("error="))
{
error = HttpUtility.ParseQueryString(e.Uri.Query).Get("error");
this.Close();
}
}
}
And i am calling this control like:
var uri = string.Format(SpotifyAuthUriFormatter, RequestAuthBaseUrl, clientId);
winOAuthBrowserForm form = new winOAuthBrowserForm(uri);
form.ShowDialog();
This is what i see:
UPDATE: When i right click on document and see the properties, i see it changes the URL to something like res://ieframe.dll/navcancl.htm#... I've searched it and found some solutions related to I.E (I'm using latest but you can't be sure that it'll be latest on client machines), some say that its firewall setting. The thing is, it appears sometimes only.
Any ideas? Thanks

What do i enter as for the "redirect Url" when creating a Facebook service?

I am trying to implement the Xamarin.Social component into my app. That requires a parameter named RedirectUrl that i can't find anywhere in the Facebook developers console, and google hardly returns results.
public static FacebookService Facebook
{
get
{
if (mFacebook == null)
{
mFacebook = new FacebookService() {
ClientId = "App ID here, that works fine",
RedirectUrl = new Uri (" ??? ")
};
}
return mFacebook;
}
}
Where can i find that parameter? I have tried various things so far but non of them seemed to work so i think its not worth posting here. I really need this for a project to get done. Thanks, i appreciate any help.
You can set this parameter on your application settings on facebook developer.
If you are developing a desktop or mobile app, you can use this url https://www.facebook.com/connect/login_success.html as your redirect_url

Facebook post from winforms app

I have setup a business account with Facebook and got my access token. Then I try and use the below code inside my WinForms App and it all passes through fine with now errors, but when I go to my Facebook page nothing has been posted to it, is there something simple I am missing here?
string acccessToken = <access token>;
FacebookClient appp = new FacebookClient(acccessToken);
try
{
appp.PostAsync("10000xxxxxx6328/feed",
new { message = "Good Morning To Me" });
}
catch (FacebookOAuthException)
{
}
Any pushes in the right direct would be great.
Thanks,
Ben

Authorizer.IsAuthorized is returning false after I have authenticated

I just started working with the Facebook SDK this weekend. I'm trying to integrate Facebook into a site. I followed the samples and documentation and got the Facebook Login button along with displaying "faces" fairly quickly (nice Toolkit).
<fb:login-button autologoutlink="true" perm="email" show-faces="true" width="200" max-rows="1"></fb:login-button>
I would like to check if the user has already been authenticated (via Facebook). This is no different than what I've seen in many of the samples. The issue, I'm having is that in my Page_Load, the authorizer.IsAuthorized is returning False even after I authenticate (my profile picture is displayed as well). Is there something that I'm missing?
protected void Page_Load(object sender, EventArgs e)
{
try
{
Facebook.FacebookApp app = new Facebook.FacebookApp();
Facebook.Web.Authorizer authorizer = new Facebook.Web.Authorizer(app);
if (authorizer.IsAuthorized())
{
}
else
{
}
}
catch (Exception ex)
{
}
}
I used 4.1.1 version of Facebook C# SDK until I've got the same problem.
Then I downloaded Version 4.2.1 and removed any Authorizer.Perms.
FacebookApp fbApp = new FacebookApp(access_token);
Authorizer fbAuth = new Authorizer(fbApp);
fbAuth.IsAuthorized();// returns true
Problem was solved.
The reason is than somehow UserId becomes 0 even you authorized application in Facebook.
They resolved it. Now when you use FacebookApp(access_token) constructor, it gets UserId from
access_token.

Categories