Automatically shortening URL for Email/Facebook shares with Bitly through AddThis API - addthis

I am unable to shorten the URL being shown in the AddThis email popup when using the built-in Bit.ly shortening service in AddThis.
It works with Twitter, but not Facebook and email. Is this supported?
var addthis_share = {
url: "http://www.wrestlemaniamainevent.com/wishlist/kjhksad897dsjkhdsa98273",
title: "View My List",
url_transforms: {
shorten: {
twitter: 'bitly',
facebook: 'bitly', // Unsupported?
email: 'bitly' // Unsupported?
}
},
shorteners: {
bitly: {
login: '{login}',
apiKey: '{key}'
}
}
}

Related

Facebook not detecting og:title, og:description, or og:image

I've built a Vue app using Nuxt.js and for some reason og: tags are not working on facebook. I see them in the source code, and run the site through the FB debugger, but it says I have no required og: meta tags.
Site here:
https://staymacro-staging.netlify.com/editorial/caleb/
Code in the page:
head () {
return {
title: `${this.title}`,
meta: [{
hid: `description`,
name: 'description',
content: `${this.description}`
},
{
hid: `og-title`,
property: 'og:title',
content: `${this.title}`
},
{
hid: `og-description`,
property: 'og:description',
content: `${this.description}`
},
{
hid: `og-image`,
property: 'og:image',
content: `${this.image}`
},
{
hid: `og-url`,
property: 'og:url',
content: `https://staymacro.com/${this.$route.path}`
}]
}
},
Sharing works on Slack, iMessage, Twitter, etc. but just not on Facebook
The og:url in the source does not match the url you presented: https://staymacro.com//editorial/caleb
That is the relevant URL where the tags are taken, and it does not work (no SSL, page not found).
You can even see this in the debugger: "Curl-Fehler: 51 (SSL_PEER_CERTIFICATE)". Check out the "canonical URL".

casperJS: how to access web site using facebook authentication?

i would use casperjs in order to crawl web site pages.
Before this, i must login to the web site. Because web site allow to login using "facebook account", i would like simulate this using casperjs.
I wasn't able to find a sample.
Could any one help me?
Thanks!
//code to setup casper instance
var casper = require('casper').create({
verbose: true,
logLevel: "debug",
waitTimeout: 7000,
resourceTimeout: 10000,
viewportSize: {
width: 1024,
height: 768
},
pageSettings: {
javascriptEnabled: true,
loadImages: true,
loadPlugins: true
}
});
//varibles required
var url = "https://www.facebook.com";
var utils = require('utils');
var x = require('casper').selectXPath;
//comamd line varibles
var user = casper.cli.args[0];
var pass = casper.cli.args[1];
// first step is to open the online resource
casper.start(url, function(response) {
console.log(url + ' is opened');
});
// code to login to your facebook account
casper.then(function () {
this.sendKeys(x('//*[#id="email"]'),user);
this.sendKeys(x('//*[#id="pass"]'),pass);
this.click(x('//*[#id="u_0_q"]'));
});
//run the script
casper.run(function() {
this.then(function () {
//take a screenshot of login
this.capture('facebook_screenshot.png');
this.exit();
});
});
The following code will log into Facebook if you could specify the website your scraping I'd be happy to write the additional code necessary to get to the Facebook login page

google-api-nodejs-client: how to call google+ domain api locally? (by the plusDomains.media.insert)

I am going to use the Nodejs google api client(google-api-nodejs-client) to post a photo to my google+. (I have listed all my code at end of this post.)
Let me introduce a little bit background:
I have created a project on: console.developers.google.com
I have enabled google+ domain API for this project.
I have created credentials for this project as well. (it is a OAuth 2.0 client ID)
I have a little bit experience of using the client (google-api-nodejs-client) and I can post images and files to my google drive by it.
However, posting to google+ photo is different, the auth is the key different. I have tried several different ways, but none of them works.
The api always return me this:
{ [Error: Forbidden]
code: 403,
errors: [ { domain: 'global', reason: 'forbidden', message: 'Forbidden' } ] }
I also found this:
Warning: The Google+ Sign-In button and the plus.login scope used by
Google+ Sign-In, are not currently supported for use with the Google+
Domains API. Requests that are made to the Google+ Domains API using
an authentication token granted for the
www.googleapis.com/auth/plus.login scope, or generated by the
Google+ Sign-In button, will fail.
If it doesn't support the sign-button, what does it support?
This page tell me to add a domain delegation (https://developers.google.com/+/domains/authentication/delegation), but i haven't push my program into any server, i just try to run it locally.
I was wondering if it is possible to use this client to post photo to google+ by run a nodejs program locally?
var CLIENT_ID = "xxxxxxx.apps.googleusercontent.com";
var CLIENT_SECRET = "xxxxxxxx";
var REDIRECT_URL = "https://xxxxxxx";
var readline = require('readline');
var async = require('async');
var google = require('googleapis');
var request = require('request');
var OAuth2 = google.auth.OAuth2;
var oauth2Client = new OAuth2(CLIENT_ID, CLIENT_SECRET, REDIRECT_URL);
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
function getAccessToken (oauth2Client, callback) {
// generate consent page url
var scopes = [
'https://www.googleapis.com/auth/plus.me',
'https://www.googleapis.com/auth/plus.stream.read',
'https://www.googleapis.com/auth/plus.stream.write',
'https://www.googleapis.com/auth/plus.circles.read',
'https://www.googleapis.com/auth/plus.circles.write',
'https://www.googleapis.com/auth/plus.media.upload'
];
var url = oauth2Client.generateAuthUrl({
access_type: 'offline', // 'online' (default) or 'offline' (gets refresh_token)
scope: scopes, // If you only need one scope you can pass it as string,
key: 'p7UALH460Deqodhvb2zESYya'
});
console.log('Visit the url: ', url);
rl.question('Enter the code here:', function (code) {
// request access token
oauth2Client.getToken(code, function (err, tokens) {
if (err) {
return callback(err);
}
// set tokens to the client
// TODO: tokens should be set by OAuth2 client.
oauth2Client.setCredentials(tokens);
console.dir(tokens);
callback();
});
});
}
getAccessToken(oauth2Client, function () {
var plusDomains = google.plusDomains({ version: 'v1', auth: oauth2Client });
var requestObj = request({url:'http://asset1.cxnmarksandspencer.com/is/image/mands/2643f540b32fe8c6cccdec95b3a2c5239166232f?$editorial_430x430$'});
const Readable = require('stream').Readable;
var iamgeStream = new Readable().wrap(requestObj);
plusDomains.media.insert({
userId: 'me',
collection: 'cloud',
resource: {
name: 'testimage.png',
mimeType: 'image/png'
},
media: {
mimeType: 'image/png',
body: iamgeStream
},
access:{domainRestricted :"true"}
}, callbackFn);
function callbackFn(argument) {
console.dir(argument);
}
});
Thanks you very much!
Peter

Facebook login on cordova app shows blank white screen

This problem has been bugging me for a long time and I can't seem to find the solution, all the settings in my Facebook Developer panel are configured correctly, Site URL, App Domain and OAuth URLs.
When I run my app on my iPhone (I have it installed through iTunes) and click the authentication button I am successfully prompted with this screen:
However, after logging in, I am faced with a blank white screen instead of being redirected to my main.html page.
I am using the OpenFB plugin along with Parse and the Facebook Graph API to authenticate and store my users data, here is my login code:
login.html:
$('.facebookLogin').click(function(){
Parse.User.logOut(); // log current user out before logging in
login();
});
function login() {
openFB.login(function(response) {
if(response.status === 'connected') {
console.log('Facebook login succeeded');
Parse.FacebookUtils.logIn("email", { // permission request to use email
success: function(user) {
if (!user.existed()) {
FB.api('/me', function(response) {
var firstName = response.first_name;
var lastName = response.last_name;
var email = response.email;
var user_id = response.id;
user.set("firstName",firstName);
user.set("lastName",lastName);
user.set("email",email);
user.save();
});
window.location.href= "main.html";
}
else {
window.location.href= "main.html";
}
},
error: function(user, error) {
alert("User cancelled the Facebook login or did not fully authorize.");
}
});
}
else {
alert('Facebook login failed: ' + response.error);
}
}, {scope: 'email'});
}
oauthcallback.html:
<html>
<body>
<script>
// redirects to main page
window.location.href= "main.html";
</script>
</body>
</html>
Note: I have added main.html, login.html and oauthcallback.html to the Valid OAuth redirect URIs list on my panel.
Check that your site is using SSL with a valid certificate.
There might be an error trying to redirect from a non-secure site to an encrypted site.

facebook api with private message multiple to (friends)

I development facebook private message for invite with facebook api.
<script>
FB.init({ appId: 'xxxxxxxxxx', xfbml: true, cookie: true });
FB.ui({
method: 'send',
to: ['1736383768','590528674'],
// picture: 'http://thinkdiff.net/iphone/lucky7_ios.jpg',
//Can be page, popup, iframe, or touch.
display: 'popup',
name: 'yyyyyy',
link: '<%=Request.QueryString["link"]%>'
});
</script>
but adds only the first mate.
how to multiple friends send private message ?
var publish =
{
method: 'stream.publish',
message: 'Some kind of test',
uid: uid,
attachment: {
name: 'Test',
caption: 'Facebook API Test',
description: ('Sure hope it worked!'),
href: 'http://www.test.com/',
media: [
{
type: 'image',
href: 'http://test.com/',
src: 'http://test.com/image.jpg'
}
]
},
action_links: [
{ text: 'Your text', href: 'http://www.test.com/' }
],
user_prompt_message: 'Share your thoughts about test'
};
publish.target_id = friendID;
FB.ui(publish);
publish.target_id = friendID;
FB.ui(publish);
return false;
You should not use stream.publish.
As said by facebook : "We are in the process of deprecating the REST API, so if you are building a new application you shouldn't use this function. Instead use the Graph API and POST a Post object to the feed connection of the User object"
So, now you have the send and feed methods left.
You cannot fill the send method with more than one user id (you can only if you are whitelisted by facebook, but I'm not quite sur how to do this , I would not count on it either).
You can use the feed method to post on many user's friends wall with something like this
FB.api('/USERID/feed', 'post', {
name:postName,
link:postLink,
picture:postPicture,
description:postDescription,
message:postMessage
}, function (postResponse) { //DO SOMETHING HERE });
But doing it, you are taking the risk of your app being deleted by facebook if someone flag it as spam.
As far as I know, sending messages to multiple friends via an App is considered bad/spam by facebook so they do not allow this anymore.
You still can Invite as many friends as you want via the App request dialog (method apprequests) but I'm not sure this is what you want.