I am getting this error while we are uploading image to facebook.And i am given the permissions.
https://graph.facebook.com/me/photos
{
"error": {
"message": "An active access token must be used to query information about the current user.",
"type": "OAuthException",
"code": 2500
}
}
This is my as3
var params:Object = {image:img, message:'vcxv', fileName:'vcxvc',name: 'My Card'};
Facebook.api('/me/photos', onSaveToPhotoAlbumComplete, params, "POST");
Please help me.
You have to add an Access Token to Object:
access_token:Facebook.getAuthResponse().accessToken
var params:Object = {image:img, message:'vcxv', fileName:'vcxvc',name: 'My Card', access_token:Facebook.getAuthResponse().accessToken};
Facebook.api('/me/photos', onSaveToPhotoAlbumComplete, params, "POST");
Related
I'm using the guide from https://docs.amazonaws.cn/en_us/amazondynamodb/latest/developerguide/GettingStarted.NodeJs.02.html to learn how to load data from a json into a dynamoDB table. I have done step 2, however, when I run my code, only some movie files are successfully put into the table and some are not. For a movie that cannot be added, I receive this error:
Unable to add movie Meet Dave . Error JSON: {
"message": "Requested resource not found",
"code": "ResourceNotFoundException",
"time": "2020-11-30T17:38:59.402Z",
"requestId": "2D23NEFAB33E62C6PEFUFGGNM7VV4KQNSO5AEMVJF66Q9ASUAAJG",
"statusCode": 400,
"retryable": false,
"retryDelay": 28.791430704572328
}
Every time I delete the db and try re-run my code, different movies are successfully added and unsuccessfully added. My code is identical to the step 2 of the guide on the link above.
var allMovies = JSON.parse(fs.readFileSync("movie_data.json", "utf8"));
allMovies.forEach(function (movie) {
var movie_params = {
TableName: "Movies",
Item: {
year: movie.year,
title: movie.title,
info: movie.info,
},
};
docClient.put(movie_params, function (err, data) {
if (err) {
console.error(
"Unable to add movie",
movie.title,
". Error JSON:",
JSON.stringify(err, null, 2)
);
} else {
console.log("PutItem succeeded:", movie.title);
}
});
});
The movie data is a json file containing a list movies with attributes: title, year and info. Does anyone have any idea why this is not working correctly i.e. not putting all of the data successfully into the db table?.
According to the react-native-fcm package you can include a custom nested object within the data object for a FCM messaging payload.
according to this post by the package author
Like this:
var payload = {
data: {
custom_notification: {
title: 'title',
body: 'body',
priority: 'high',
id: 'id',
group: 'group'
}
}
};
This is for the purpose of receiving heads up notifications in all app states, which will not happen if you do just a notification payload or data payload.
When I implement this in my cloud function I get the following error:
Error: Messaging payload contains an invalid value for the "data.custom_notification" property. Values must be strings.
So I'm at a loss as to how others can be using this successfully?
I wonder if there's some issue going on with my environment or something as the following test payload which was given to me by firebase support (and is in the docs) errors out:
var payload = {
"to":"FCM_TOKEN",
"data": {
"type":"MEASURE_CHANGE",
"body": "test body",
"title": "test title",
"color":"#00ACD4",
"priority":"high",
"id": "id",
"show_in_foreground": true
}
};
I get the following error:
Error sending message stringify: {"code":"messaging/invalid-payload","message":"Messaging payload contains an invalid \"to\" property. Valid properties are \"data\" and \"notification\"."}
Been at this for days so hopefully I can get a bit of help on this.
Thanks in advance!
So I realised just now (after days of searching) that the package react-native-fcm is using a different send method than admin.messaging().sendToDevice(token, payload, options). I had been using that for a while now and didn't realize that it was not actually what was intended to be used with this library or atleast in this scenario. Mainly because everything was working fairly well using admin.messaging() up until I wanted heads up notifications in all app states.
The other method is like this
sendData(token) {
let body = {
"to": token,
"data":{
"title": "Simple FCM Client",
"body": "This is a notification with only DATA.",
"sound": "default",
"click_action": "fcm.ACTION.HELLO",
"remote": true
},
"priority": "normal"
}
this._send(JSON.stringify(body), "data");
}
_send(body, type) {
let headers = new Headers({
"Content-Type": "application/json",
"Content-Length": parseInt(body.length),
"Authorization": "key=" + FirebaseConstants.KEY
});
fetch(API_URL, { method: "POST", headers, body })
.then(response => console.log("Send " + type + " response", response))
.catch(error => console.log("Error sending " + type, error));
}
You can use nested objects within the data object using this method. The documentation is not super clear on this unfortunately, I didn't even realise there was an example until now. Of course this could have just been me.
When using the data message payload, it is stated to use key value pairs that are String, so what you could do is have the value of your custom_notification as JSON String by enclosing them in " ".
For the sample payload provided, are you actually using the FCM_TOKEN in the to parameter? You're supposed to replace it with an actual token.
I am working on creating labels using JavaScript Gmail API.
function createLabel(userId, newLabelName, callback) {
var request = gapi.client.gmail.users.labels.create({
'userId': userId,
'label': {'name': newLabelName}
});
request.execute(callback);}
This is the code of Developer API Example
I am able to authenticate and even I'll get the label list but while creating the label I am getting the below error.
{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalidArgument",
"message": "Invalid request"
}
],
"code": 400,
"message": "Invalid request"
}
}
But when I am using the Try It example It's working but only difference is it's do the POST request with key={Your auth key} which the example provided won't attach that part to URL.
The data you send should be in the resource-parameter, and labelListVisibility and messageListVisibility are also mandatory fields:
function createLabel(userId, newLabelName, callback) {
gapi.client.gmail.users.labels.create({
userId: userId,
resource: {
name: newLabelName,
labelListVisibility: 'labelShow',
messageListVisibility: 'show'
}
}).execute(callback);
}
I am trying to delete a playlist that I have created but keep receiving a 404 error.
I have a global var playlistId to remember the playlistId that I have created.
var playlistId
I create the playlist like so :
function createPlaylist() {
var request = gapi.client.youtube.playlists.insert({
part: 'snippet,status',
resource: {
snippet: {
title: 'hard coded title',
description: 'Hard Coded Description'
},
status: {
privacyStatus: 'private'
}
}
});
request.execute(function(response) {
var result = response.result;
if (result) {
playlistId = result.id;
console.log("created playlist " + playlistId)
}
});
}
Then I delete a playlist like so :
function deletePlaylist() {
var request = gapi.client.youtube.playlistItems.delete({
id: playlistId
}).execute();
}
404 Error that I receive is :
{
"error": {
"errors": [
{
"domain": "youtube.playlistItem",
"reason": "playlistItemNotFound",
"message": "Playlist item not found.",
"locationType": "parameter",
"location": "id"
}
],
"code": 404,
"message": "Playlist item not found."
}
}
I am giving the playlistId of the PlayList that I have created yet the playlist can not be deleted.
Can anyone give some guidance?
deletePlaylist appears to be attempting to delete a PlaylistItem (i.e. a video) rather than a Playlist itself. Could you try replacing playlistItems with playlists?
I have a requirement to update twitter status with media . I am using following Twitter API for it.
https://dev.twitter.com/docs/api/1.1/post/statuses/update_with_media.
Doing this with nodejs twit library "https://github.com/ttezel/twit"
twit = new Twit({
consumer_key: TWITTER_OAUTH_KEY
, consumer_secret: TWITTER_OAUTH_SECRET
, access_token: 'access token'
, access_token_secret: 'secret'
});
wallpost = {};
wallpost.status = 'media upload1 deliverdfd\nhttp://www.animalplanet.com/';
wallpost.media = [{
"media_url": "http:\/\/pbs.twimg.com\/media\/A7EiDWcCYAAZT1D.jpg",
"media_url_https": "https:\/\/pbs.twimg.com\/media\/A7EiDWcCYAAZT1D.jpg",
"url": "http:\/\/t.co\/bAJE6Vom",
"display_url": "pic.twitter.com\/bAJE6Vom",
"expanded_url": "http:\/\/twitter.com\/BarackObama\/status\/266031293945503744\/photo\/1",
"type": "photo",
}];
My post request
twit.post( "update_with_media", wallpost, function(err, res2) {
if (err) {
return next(err);
}
console.info(res2);
// returns the post id
res.json({
status: 200,
info: "OK",
id: res2.id
});
});
Am getting an error message [{"code":195,"message":"Missing or invalid url parameter"}]}.
I have googled it found some threads some of them mentioning about set content type multipar form data. But i don't know how to set content type.
I have tried
var multipart = [{
"Content-Type": "multipart/form-data"
}];
wallpost.content_type = multipart;
not working for me. Please help me to solve this issue. Thank you
From the documentation you linked to
Supported image formats are PNG, JPG and GIF, including animated GIFs of up to 3MB . This data must be either the raw image bytes or encoded as base64.
You can only upload images - not links to images. Save an image locally and add it to media as a base64 encoded string.
You can not send links - even to Twitter images.