Does a link to a facebook profile picture stay up to date or should I store images in storage?
I am using firebase and facebook authentication and grabbing a users profile picture link like this when they FIRST create an account:
const photoLarge = await getFacebookUserInfo().then((userResponse) => {
return userResponse.picture.data.url.toString()
}).catch((error) => {
return error
});
const userId = await firebaseService.auth().currentUser.uid;
writeUserData(
userId,
photoLarge,
);
}
For some reason I noticed in dev vs prod I have 2 different links with the dev not working.
Dev doesn't work:
https://platform-lookaside.fbsbx.com/platform/profilepic/?asid=10161383578450224&height=200&width=200&ext=1558132998&hash=AeTUIkafEn5zw5PF
Prod Does:
https://platform-lookaside.fbsbx.com/platform/profilepic/?asid=10161383578450224&height=200&width=200&ext=1558673410&hash=AeQGA8guHyxIK9du
I am trying to figure out if the facebook picture should be downloaded and stored in storage and then referenced instead and if so how to go about doing that? (/ is there a expiration date on a link)
I haven't seen if this is happening or not for Google Sign-in.
Here is my graph request:
//graph QL request to get larger facebook profile
export const getFacebookUserInfo = () => {
return new Promise((resolve, reject) => {
const infoRequest = new GraphRequest(
'/me',
{
parameters: {
fields: {
string: 'email,about,name,picture.type(large)'
}
}
},
(error, data) => {
if (error) {
reject(error);
} else {
resolve(data);
}
}
);
new GraphRequestManager().addRequest(infoRequest).start();
})
}
So somehow I finally figured this out today. Essentially the graphAPI spits back several pieces with one being a picture piece. This looks like the links I posted above https://platform-lookaside.fbsbx.com/platform/profilepic
THIS CHANGES!!! Not sure how often, but do NOT use this as eventually it will be a dead link.
However, what I missed was that you can use the ID that the graphAPI spits back instead and use the following link:
http://graph.facebook.com/{your_id_goes_here}/picture?type=large&redirect=true&width=500&height=500
More information can be found in this other post:
Get user profile picture by Id
Related
I'm trying to create an asset report from Plaid, I'm using Cloud Functions for these calls, all the other cloud functions work (link, transactions, balance) but assetReportCreate fails and return UNAUTHENTICATED

The Plaid logs do not show the call...so I guess something is wrong in my Cloud Function, but the Google Console Logs show status 200.
has anybody experienced the same issue and know how to fix it?
PS: just double checked today to make sure I'm authenticated and I am...
//create ASSET report
exports.createAssetReport = functions.https.onCall(async (data, context) => {
const accessToken = data.accessToken;
const daysRequested = data.daysRequested;
// const options = {
// client_report_id: '123',
// webhook: "https://www.example.com", //to let you know when report is ready, get link from cloud console
// };
const configuration = new Configuration({
basePath: PlaidEnvironments[functions.config().app.env],
baseOptions: {
headers: {
"PLAID-CLIENT-ID": functions.config().plaid.client_id,
"PLAID-SECRET": functions.config().plaid.secret,
},
},
});
const plaidClient = new PlaidApi(configuration);
//call the createLinkToken METHOD of the plaidClient instance!
return plaidClient
.assetReportCreate({
access_tokens: [accessToken],
days_requested: daysRequested,
//options,
})
.then((response) => {
const assetReportId = response.data.asset_report_id;
const assetReportToken = response.data.asset_report_token;
return assetReportToken; //token is needed to retrieve the report via //pdf/get
})
.catch((err) => {
console.log(err);
throw new functions.https.HttpsError(
"internal",
" Unable to create asset report: " + err
);
});
});
I found that for whatever reason the function wasn't open for all users to invoke, adding a principal with role: "cloud functions invoker" fixed the issue, shame on you google cloud, I spent two full days on this!! jk, thanks for your services but fix these small details and you could become the #1 cloud provider
I followed the docs to use the Facebook Login SDK. Everything works except for the fact that the token that is generated does not work for our API. Our API takes the user-generated token as a header so that it can make requests. I know the reason why it isn't working is that I am logging in with Facebook, but there is no account created on our API. Facebook will not give me access to a user's password (for obvious reasons), so I can't generate an account from the information provided from Facebook.
I think the answer lies with App Access Tokens. If someone could help me out I would really appreciate it!
code:
export const logInFB = () => async dispatch => {
const { type, token } = await Expo.Facebook.logInWithReadPermissionsAsync('**Blocking this out**', {
permissions: ['public_profile'],
});
console.log('token');
console.log(token);
if (type === 'success') {
// Get the user's name using Facebook's Graph API
const response = await fetch(
`https://graph.facebook.com/me?access_token=${token}`);
console.log('fb token')
console.log(response);
dispatch(fbLoginToken(token));
Alert.alert(
'Logged in!',
`Hi ${(await response.json()).name}!`,
);
}
}
Looks like you are missing the fields property in the URL. ex: &fields=id,name,email,about,picture
Please refer to this example: https://snack.expo.io/#bacon/facebook
const response = await fetch(
`https://graph.facebook.com/me?access_token=${token}&fields=id,name,email,about,picture`
);
const responseJSON = JSON.stringify(await response.json());
this.setState({ responseJSON });
I need to fetch user photos and albums using the Facebook Graph API.
As far as I understand (while reading the docs) this is a two step procedure, 1. fetching the id for each photo from the photos edge, 2. using the returned array of ids, fetching individual photo nodes.
Fetching individual photo nodes could mean hundreds of requests/s, while having a lot of photos on my profile I have hit the app request limits after a few minutes of testing.
Is there maybe a way to fetch all photos at once (or in fewer requests), in order to avoid request limits?
example implementation:
...
var photos = [];
function fetchPhotos(){
fetch('https://graph.facebook.com/v3.1/me/photos?type=uploaded&access_token=' + accesstoken, {
method: 'GET'
})
.then(photos => photos.json())
.catch(error => console.error('Error:', error))
.then(photos => {
this.fetchPhoto(photos);
});
}
function fetchPhoto(photos){
for(var i=0; i < photos.data.length; i++){
fetch('https://graph.facebook.com/v3.1/' + photos.data[i].id + '?fields=link,width,height&access_token=' + accesstoken, {
method: 'GET'
})
.then(photo => photo.json())
.catch(error => console.error('Error:', error))
.then(photo => {
photos.push(photo);
});
}
}
...
Thanks!
You can already get a list with all the fields with one call:
https://graph.facebook.com/v3.1/me/photos?fields=link,width,height&access_token=...
Side Note: If that is client code, why not use the official JS SDK? That way, you don´t need to deal with the Access Token, it gets added automatically.
I am trying to get the reviews for my app from the playstore using the new reviews api from the android publisher service.
The app key is me.jadi (https://play.google.com/store/apps/details?id=me.jadi) as you can see it have reviews posted for it.
Here is the code I'm using:
var google = require('googleapis');
var secrets = require('./secrets.json');
var androidpublisher = google.androidpublisher('v2');
var authClient = new google.auth.JWT(
secrets.client_email, null, secrets.private_key,
['https://www.googleapis.com/auth/androidpublisher'], null);
authClient.authorize(function (err, tokens) {
if (err) {
return console.log(err);
}
androidpublisher.reviews.list({ auth: authClient, packageName: 'me.jadi' }, function (err, resp) {
if (err) {
return console.log(err);
}
});
});
It doesn't contain any errors for the auth nor for the actual service request. But the result is always an empty object.
So I'm trying to identify the problem,
is there something wrong with the code
do I need to opt-in specifically somewhere to use the API
does the API have any limitations, like geographic (the service is allowed only for the US devs)
or maybe the service have some bugs because it is still in beta
I found the answer my self, and I'll post it here for future reference.
The problem with my specific case was that I didn't have reviews posted or modified in the last week.
And the API documentation clearly states that it will keep history of the reviews in the last seven days.
Once I get a new review I tried the code and the review was successfully retrieved.
My application uses the Facebook Javascript SDK to add wall posts to the feed of a community's page, and to retrieve them again. Pictures included with the posts are processed and placed somewhere on the Facebook servers.
When these posts are retrieved the links to the pictures turn out to be links pointing to the fbcdn.net server.
Is there a way to access the original links?
Update:
Here is my code posting a post:
// The "params" variable contains a field called "picture"
// (which is a link pointing to my picture)
FB.addWallPost = function (params, pageId, token, complete) {
var fbApiParams = {
access_token: token
};
$.extend(fbApiParams, params);
FB.api(pageId + '/feed', 'post', fbApiParams, function (response) {
// FB.apiCallDone is a function checking if there's any positive response
if (FB.apiCallDone(response)) {
complete(response.id);
}
else {
complete(null);
}
});
}
And these lines retrieve the posts:
FB.getWallPosts = function (wallPostsIds, token, complete) {
if (wallPostsIds && wallPostsIds != null && wallPostsIds.length) {
var wallPostsIdsStr = wallPostsIds.join(',');
var fbApiParams = {
ids: wallPostsIdsStr,
access_token: token
};
FB.api('/', fbApiParams, function (response) {
if (FB.apiCallDone(response)) {
var wallPosts = dictElemsToArr(response);
complete(wallPosts);
}
else {
complete([]);
}
});
}
else {
complete([]);
}
}
If you're posting pictures to Facebook, they will be stored locally by Facebook.
It is up to your application to store the path of the original images if your application requires this information.