dimanche 1 mars 2015

Unable to Share from Latest ShareButton CodenameOne api

Hello I have integrated the Facebook Demo into netbeans and followed the guidelines as mentioned in the developer guide and as well as set required facebook permissions. But im failing to share the text on to the wall, where as am able to retirve friends list, profile info and news feed.



final ShareButton share = new ShareButton();
final TextArea t = new TextArea(" This is sample text from using CodenameOne api");
t.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent evt) {
share.setTextToShare(t.getText());
}
});
c.addComponent(BorderLayout.CENTER, t);
share.setTextToShare(t.getText());


Is there anything which im missing to integrate or set any additioanl permissions?


NodeJS Facebook User Feed Subscriptions: Invalid OAuth access token

Am close to tearing my hair out (as a passionate developer, should), so hopefully I can get some help on this one. After reading a bunch of forums and sifting through facebook documentation, here is a log file of trying to make a subscription to user feed's. I really only need to know if the bottom set of API's I am running should work in theory. Here is my log:



*********************************************************
makeRequest - Host: graph.facebook.com - Path: /v2.2/{ app_id }/subscriptions?object=user
*********************************************************
Type: DELETE
*********************************************************
Wed Feb 25 2015 12:52:15 GMT+0000 (UTC) Server is listening on port 81
*********************************************************
makeRequest - Host: graph.facebook.com - Path: /oauth/access_token?client_id={ app_id }&client_secret={ app_secret }&grant_type=client_credentials
*********************************************************
Type: GET
*********************************************************
App Access Token: { app_token }
*********************************************************
makeRequest - Host: graph.facebook.com - Path: /v2.2/{ app_id }/subscriptions?&object=user&fields=feed&callback_url={ uri_encoded_ callback_url }&verify_token={ verify_token }&access_token={ app_token }
*********************************************************
Type: POST
*********************************************************
Success: {"error":{"message":"Invalid OAuth access token.","type":"OAuthException","code":190}}


So here I am first trying to delete any subscriptions currently active, then using the API to get issued a new application access token, and finally to make a new subscription. Here is my function to initialize this whole process:



function subscribe_facebook(http,https) {
var oauth_obj = getOauthObj('facebook');

// First Delete
var url = oauth_obj.subscription_url;
var host = splitUrl(url,"host");
var path = splitUrl(url,"path");

path += "?object=user";

makeRequest(http,host,path,80,'DELETE',function(ret){
// Get App Access Token
url = oauth_obj.access_token_url;
host = splitUrl(url,"host");
path = splitUrl(url,"path");

path += "?client_id=" + oauth_obj.app_id;
path += "&client_secret=" + oauth_obj.app_secret;
path += "&grant_type=client_credentials";

makeRequest(https,host,path,443,'GET',function(ret){
facebook_app_token = ret.toString().split('|');
facebook_app_token = facebook_app_token[1];
consoleLogger("App Access Token: " + facebook_app_token);

subscribe(https,'facebook',443,'POST',facebook_app_token,myServer);
});
});
}


And here is the subscribe function it enters:



function subscribe(http,type,port,method,access_token,myServer) {
var oauth_obj = getOauthObj(type);
var sub_post_data = "";
switch (type) {
case "facebook":
sub_post_data =
"&object=" + "user"+
"&fields=" + "feed"+
"&callback_url=" + encodeURIComponent(myServer + "/" + type) +
"&verify_token=" + "*****" +
"&access_token=" + access_token
break;
}

var host = splitUrl(oauth_obj.subscription_url,"host");
var path = splitUrl(oauth_obj.subscription_url,"path");
path += "?" + sub_post_data;

makeRequest(http,host,path,port,method,function(ret) {
consoleLogger("Success: " + ret);
});
}


I made this other function to maintain the social media variables:



function getOauthObj(type) {
var obj = {};
var authorize_url = "";
var access_token_url = "";
var request_token_url = "";
var subscription_url = "";

var app_id = "";
var app_secret = "";

var main_domain = "";
var scope = "";

switch (type) {
case "facebook":
app_id = '*****';
app_secret = '**********';

main_domain = 'http://ift.tt/wljqS4';
authorize_url = 'http://ift.tt/OJg2cb';
access_token_url = main_domain + 'oauth/access_token';
request_token_url = main_domain + '2.2/me';
subscription_url = main_domain + "v2.2/" + app_id + "/subscriptions";
scope = 'read_stream';
break;
}
obj.main_domain = main_domain;

obj.authorize_url = authorize_url;
obj.access_token_url = access_token_url;
obj.request_token_url = request_token_url;
obj.subscription_url = subscription_url;

obj.app_id = app_id;
obj.app_secret = app_secret;

return obj;
}


Being that the OAuth is invalid, I'm assuming that I'm not passing the right parameters to the oauth API to do this or not - can someone steer me in the right direction?


Connect with Facebook Twitter g+ LinkedLn

I have a form to login, and I want to boost it with Facebbok, Twitter, G+ and linkedLn. What is the easier way to use script to login in please?



<div class="social" id="social">
<ul>
<li><a href="#"> <i class="facebook"> </i> </a></li>
<li><a href="#"><i class="twitter"> </i> </a></li>
<li><a href="#"><i class="google"> </i> </a></li>
<li><a href="#"><i class="linkedin"> </i> </a></li>
<div class="clear"> </div>
</ul>
</div>

When FBIDE will be released?

FB guys on some talk you said, that it will be in summer 14', but now already spring 15'. Do you have any plans?


Currently one big blocker to move to Hack language is missing plugins for popular free IDEs like eclipse/netbeans/other (atom with it's "code completion" is not a good IDE).


How I can logout from Facebook in my custom android app?

I am building an android application where I am using facebook login and after facebook login I get access_token and session that are stored in shared preferences in private mode.


I am using the below facebook login code in an activity and i want the user to logout from facebook from another fragment. How do i code on the fragment so that my current logged-in account logs out from facebook.


Here is my facebook login code -



/**
* Function to login into facebook
*/
@SuppressWarnings("deprecation")
public void loginToFacebook() {

mPrefs = getPreferences(MODE_PRIVATE);
String access_token = mPrefs.getString("access_token", null);
long expires = mPrefs.getLong("access_expires", 0);

if (access_token != null) {
facebook.setAccessToken(access_token);
// call getprofileinformation function to get user details
getProfileInformation();

Log.d("FB Sessions", "" + facebook.isSessionValid());
}

if (expires != 0) {
facebook.setAccessExpires(expires);
}

if (!facebook.isSessionValid()) {
facebook.authorize(this,
new String[]{"email", "publish_stream"},
new Facebook.DialogListener() {

@Override
public void onCancel() {
// Function to handle cancel event
}

@Override
public void onComplete(Bundle values) {
// Function to handle complete event
// Edit Preferences and update facebook acess_token
SharedPreferences.Editor editor = mPrefs.edit();
editor.putString("access_token",
facebook.getAccessToken());
editor.putLong("access_expires",
facebook.getAccessExpires());
editor.commit();

// call getprofileinformation function to get user
// details
getProfileInformation();

}

@Override
public void onError(DialogError error) {
// Function to handle error

}

@Override
public void onFacebookError(FacebookError fberror) {
// Function to handle Facebook errors

}

});
}
}


Help is appreciated, thanks!


How to style Facebook and Twitter share buttons?

I have added Facebook share button and it forks fine, but I have problems with style. I want to change button style, make my custom style. I have tried to put style in my own style.css calling classes that I find using Fire Bug but when I put my own style using those classes nothing happens, it's like I haven't add any style.


This is how my code look like



<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'your-app-id',
xfbml : true,
version : 'v2.1'
});
};

(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>


HTML:



<div class="fb-share-button" data-href="http://localhost/dfs/jersey.php" data-layout="button_count"></div>


Can anybody help me please?


Also I have same problem with Twitter button.


Thank you.


samedi 28 février 2015

Launch Google Play Games App using WEBINTENT plugin

I want to open Google play games app on my mobile from my android phonegap build application using WEBINTENT plugin.



window.plugins.webintent.startActivity({
action: window.plugins.webintent.ACTION_VIEW,
url: 'facebook://'
},
function() {alert('success')},
function(errorMsg) {alert('Failed to startActivity errorMsg=' + errorMsg)}
);

},false);


This code works well to open facebook. How to use it to open play games application.? Thanks.