I'm using AxSU3D's Android plugin in a Unity project. When I try to use the Facebook Login method, I get an error that says "The parameter app_id is required"
I have posted my code below. I have REPLACED the string "fbAppID" with the actual ID. This is just the sample script that came with the plugin that I am trying to use.
Any help will be appreciated
using UnityEngine;
using System.Collections;
using AxSAndroidPlugin.Core;
using AxSAndroidPlugin.Social.Facebook;
public class FacebookSample : MonoBehaviour {
public string fbAppID = "YOUR_FACEBOOK_APP_ID_HERE";
public GameObject picture;
//Texture2D tex;
void OnGUI () {
if(GUI.Button(GUIControls.GetButtonRect(1), "Init" ))
Facebook.Init(fbAppID);
if(GUI.Button(GUIControls.GetButtonRect(2), "Login" ))
Facebook.Login();
if(GUI.Button(GUIControls.GetButtonRect(3), "IsLoggedIn"))
Facebook.IsLoggedIn();
if(GUI.Button(GUIControls.GetButtonRect(4), "User Info")) {
Facebook.GetUserInfo();
}
if(GUI.Button(GUIControls.GetButtonRect(5), "Friends")) {
Facebook.GetFriendsList();
}
if (GUI.Button (GUIControls.GetButtonRect (6), "Load Profile Picture")) {
Facebook.LoadProfilePicture();
}
if (GUI.Button (GUIControls.GetButtonRect (7), "Get Profile Picture")) {
Texture2D tex = Facebook.GetProfilePicture();
picture.renderer.material.mainTexture = tex;
}
if(GUI.Button(GUIControls.GetButtonRect(8), "Send Request")) {
Facebook.SendRequest("This Plugin Rocks!");
}
if(GUI.Button(GUIControls.GetButtonRect(9), "Post To Timeline")) {
string name = "AxS Android Plugin";
string caption = "AxS Android Plugin for Unity";
string description = "A complete solution to all your Android native needs!";
string link = "http://www.axsu3d.com/";
string pictureLink = "http://www.axsu3d.com/DLs/axsu3dLogo.png";
Facebook.PostToTimeline(name, caption, description, link, pictureLink);
}
//Get the user's likes
if(GUI.Button(GUIControls.GetButtonRect(10), "User Likes")) {
Facebook.GetUserLikes();
}
//Logout of Facebook
if(GUI.Button(GUIControls.GetButtonRect(11), "Logout" ))
Facebook.Logout();
if(GUI.Button(GUIControls.GetButtonRect(12), "Back"))
Application.LoadLevel("CoreSample");
}
}
Firstly, wow. I didn't realize something I helped make would show up on SO.
The solution is quite simple, really. You probably did not use the "Merge Manifest" option.
You can find this option under "Tools/AxSU3D/Android/Merge Manifest". This will show a window where you can put in your Facebook app ID.
The option will create or merge a new AndroidManifest.xml file, which will also contain your Facebook App ID.
Try it out.
Related
I am trying to create a login module from the tutorial and will be using the login user id as target in my next step :sent_EventBased_Push_notification
https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/7.1/authentication-security/adapter-based-authentication/adapter-based-authentication-native-android-applications/
Done no changes just downloaded those sample project from github and run then in mfp and android studio as it is.And they did work wonderfully.
But in mobilefirst console though I saw the the device got registered there is no user id against it..What I mean is I am using a nexus4 to login and login id s 'my-phn-no'.So user Id should be 'my-phn-no'.
below I am pasting my AuthAdapter-impl.js [same as eg.]
function onAuthRequired(headers, errorMessage){
errorMessage = errorMessage ? errorMessage : null;
return {
authStatus: "credentialsRequired",
errorMessage: errorMessage
};
}
function submitAuthentication(username, password){
if (username==="8907870678" && password === "password"){
var userIdentity = {
userId: username,
displayName: username,
attributes: {
foo: "bar"
}
};
//WL.Server.sendMessage("Hello", "hi,gd mg")
WL.Server.setActiveUser("AuthRealm", userIdentity);
return {
authStatus: "complete"
};
}
return onAuthRequired(null, "Invalid login credentials");
}
function getSecretData(){
return {
secretData: "12345 changed for trial"
};
}
function onLogout(){
WL.Logger.debug("Logged out");
}
Can you please point out the part I am missing/how do I implement it. Thank you in advance.
I tried the same code in SIT environment where it have the actual product installed MFP 7.1 . It worked perfectly .
I guess there is some thing going wrong in my eclipse plugin.
I have this ionic app where I put code to open the browser and go to app store or google play, depending on OS.
The call to App Store works. The string for app store is:
market = 'https://itunes.apple.com/us/app/my_app_name/id12345';
while for android is:
market = 'market://details?id=<package_name>';
The code to open the browser is:
cordova.InAppBrowser.open(market, '_blank', 'location=yes');
When I try to open in android, some kind of browser opens and displays the message:
"Web page not available. The webpage at market://details?id=my_app_id might be temporarly down ..."
Before this, the string for google play was the one you normally use in a browser, which is:
http://play.google.com/store/apps/details?id=<package_name>
In that case the message was about the broser not supporting the call to google play. It asked if I wanted to download google play app.
I guess the right way is to use the "market"-prefix? But still dont understand why its not showing the app.
Ok, so I looked into 'cordova-plugin-market' source code for ios. This is how the url to appstore is built:
NSString *url = [NSString stringWithFormat:#"itms-apps://itunes.apple.com/app/%#", appId];
And this is how url looks if you want to navigate from PC browser:
https://itunes.apple.com/app/id333903271 (twitter for example)
So if you use this plugin for Ios, consider adding 'id' prefix, and instead of using bundle Id (package name) use Apple ID of your app. For android of course com.example.package will be enough
let appId;
if (this.platform.is("android")) {
appId = "com.example.package"
} else {
appId = "id1234567"
}
this.market.open(appId).then(response => {
console.debug(response);
}).catch(error => {
console.warn(error);
});
}
I added
cordova plugin add https://github.com/xmartlabs/cordova-plugin-market
And then it worked.
import { InAppBrowserOptions, InAppBrowser } from '#ionic-native/in-app-browser';
import { Market } from "#ionic-native/market";
import { Platform } from "ionic-angular";
constructor(private market:Market, private inappBrowswer:InAppBrowser,
private platform:Platform)
{
this.onUpdateNow();//Call the update function
}
onUpdateNow() {
this.platform.ready().then(() => {
if (this.platform.is("ios")) {
//replace '310633997' with your iOS App ID
this.openInAppStore('itms-apps://itunes.apple.com/app/310633997'); //call the openInAppStore
} else if (this.platform.is("android")) {
//replace 'com.whatsapp.saint' with your Android App ID
this.market.open("com.whatsapp.saint").then(response => {
console.log(response);
}).catch(error => {
console.log(error);
});
}
});
}
openInAppStore(link) {
let options: InAppBrowserOptions = {
location: 'yes',//Or 'no'
};
let target = "_blank";
this.inappBrowswer.create(link, target, options);
}
I tried the plugin with capacitor and its working like a charm using the package name and the app id (for android and ios accordingly):
public goToStore() {
const appId = 1234512345;
const packageName = 'com.test.app';
Capacitor.getPlatform() === 'android' ? this.market.open(packageName) : this.market.open(appId);
}
The plugins:
"#ionic-native/market": "5.36.0",
"cordova-plugin-market": "1.2.0",
I am using Xamarin Forms and want to integrate Facebook in android app. I want to pull the feed from a page like https://www.facebook.com/HyundaiIndia
I have installed Xamarin.Facebook from Nuget. It doesn't have a FacebookClient object as mentioned in here: https://components.xamarin.com/gettingstarted/facebook-sdk
Then I found the Xamarin.Facebook and Xamarin.FacebookBolts namespaces which I included, but I still didn't get FacebookClient. Instead I found Xamarin.Facebook.XAndroid.Facebook and I created an instance:
Xamarin.Facebook.XAndroid.Facebook fb = new Xamarin.Facebook.XAndroid.Facebook(FacebookAppId);
But this object doesn't have GetTaskAsync. How do I pull down the feeds in Xamarin?
I had the same experience trying following the article you mentioned.
The component created by Outercurve Foundation (Facebook.dll version 6.2.1)
needs that you reference Facebook.dll and you include it in your file like this:
using Facebook;
Don't confuse it with:
using Xamarin.Facebook;
EDIT
I finally found a bit of time for a more complete answer and since the example on the link
doesn't specify how to obtain the AccessToken (called userToken in the facebook-sdk component page example linked in the question) I'm posting one of the possible solutions.
This one works for me and doesn't require any other library or component (but the one already mentioned in the question).
using Xamarin.Auth;
using Facebook;
string FaceBookAppId = "YOUR_FACEBOOK_APP_ID";
string AccessToken;
string OauthTokenSecret;
string OauthConsumerKey;
string OauthConsumerSecret;
void GetFBTokens()
{
var auth = new OAuth2Authenticator(FaceBookAppId,
"",
new Uri("https://m.facebook.com/dialog/oauth/"),
new Uri("https://www.facebook.com/connect/login_success.html")
);
auth.Completed += (sender, eventArgs) =>
{
if (eventArgs.IsAuthenticated)
{
eventArgs.Account.Properties.TryGetValue("access_token", out AccessToken);
eventArgs.Account.Properties.TryGetValue("oauth_token_secret", out OauthTokenSecret);
eventArgs.Account.Properties.TryGetValue("oauth_consumer_key", out OauthConsumerKey);
eventArgs.Account.Properties.TryGetValue("oauth_consumer_secret", out OauthConsumerSecret);
}
};
}
//Now we can use the example of the link.
void PostToMyWall ()
{
FacebookClient fb = new FacebookClient (AccessToken);
string myMessage = "Hello from Xamarin";
fb.PostTaskAsync ("me/feed", new { message = myMessage }).ContinueWith (t => {
if (!t.IsFaulted) {
string message = "Great, your message has been posted to you wall!";
Console.WriteLine (message);
}
});
}
There are 2 editions of Facebook SDK, one is binding for official SDK, another is from Outercurve Foundation.
Looks like you're using this one: the "official" binding , so check the documentation on this link.
Im working on a unity game where you can take a picture and upload this picture to facebook from unity along with some tags and stuff (much like friendsmash). The problem is that i do not have a web-server that i can put the screenshots on, and the Fb.Feeb(picture:) attribute only accepts urls.
I have read that you can use HTTP POST to post the picture to the users images and then use that link in picture:, but i dont know anything about HTTP POST and i couldnt figure out how to do it.
I have also read that you can use FB.API() to somehow do this, but i couldnt figure it out.
Any sample code would be greatly appreciated.
My current code:
private string _path = "file://" + System.IO.Path.Combine(Application.persistentDataPath, "Images/image.png");
void Start ()
{
if (!FB.IsLoggedIn)
FB.Login("email, publish_actions, publish_stream, user_photos", LoginCallback);
StartCamera();
}
private void OnBragClicked()
{
FbDebug.Log("OnBragClicked");
//Post(); <-- dont know how
FB.Feed(
linkCaption: "#hashtag",
picture: "???",
linkName: "Im hashtaging!",
link: "https://apps.facebook.com/" + FB.AppId + "/?challenge_brag=" + (FB.IsLoggedIn ? FB.UserId : "guest")
);
}
void TakeSnapshot()
{
_snap = new Texture2D(_webCamTexture.width, _webCamTexture.height);
_snap.SetPixels(_webCamTexture.GetPixels());
_snap.Apply();
//System.IO.File.WriteAllBytes(_path, _snap.EncodeToPNG());
}
The facebook sdk does have a way to make this happen after all. You need to use Fb.API().
This is the way it worked for me:
private void TakeScreenshot()
{
var snap = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false);
snap.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0);
snap.Apply();
var screenshot = snap.EncodeToPNG();
var wwwForm = new WWWForm();
wwwForm.AddBinaryData("image", screenshot, "barcrawling.png");
FB.API("me/photos", HttpMethod.POST, LogCallback, wwwForm);
}
In general terms, to add some sort of caption, it's along the lines...
private byte[] postcardAsBytes;
string textMessage = "Play this great game at http://blah.com.";
Dictionary<string, object> d = new Dictionary<string, object>
{
{ "message", textMessage },
{ "picture", postcardAsBytes }
};
Facebook.instance.graphRequest(
"me/photos", HTTPVerb.POST, d, yourCompletionHandler);
// in this example using the prime31 plugin, rather than the fb sdk
The key field seems to be "message". Confusingly, the "dictionary" field documented by FB, seems to just not work, so try "message" at first.
I am using Android Market api.
I use it to retrieve all the comments to my app:
http://code.google.com/p/android-market-api/wiki/HowToGetAppComments
My question is how can I know what is the authorId of the current user?
I just need to know if that user already write a comment or not.
Thanks!
The example code at the link you posted shows this:
public void onResult(ResponseContext context, CommentsResponse response)
{
System.out.println("Response : " + response);
// response.getComments(0).getAuthorName()
// response.getComments(0).getCreationTime()
// ...
}
Based on the source code , to get theauthorID of the first comment for example, you should be able to use
String id = response.getComments(0).getAuthorID();