I have a JavaScript function to post image with Graph API.
function postOpenGraphFromUrl(imageUrl, pageUrl, callback) {
var options = {
'photo' : pageUrl,
'image[0][url]' : imageUrl,
'image[0][user_generated]' : true
};
FB.api('/me/hairchalk:create', 'post', options, function(response) {
if (callback && typeof callback == 'function') {
callback(response);
}
});
}
When I try to execute I have this error in response:
/**/ FB.__globalCallbacks.f4c69a98({"error":{"type":"Exception","message":"The user generated photo at https:\/\/hairchalk.ltst.su\/uploads\/look\/file\/7\/large_photo.jpg could not be uploaded because: cURL Error [#60, CURLE_SSL_CACERT]: Transfer failed.","code":1611180}});
As I can see from the error message there is kind of problem with curl, but on my side I don't use curl at all. How can I solve this problem?
Adding the chain certification fixed this for me. Here's some instructions: http://www.entrust.net/knowledge-base/technote.cfm?tn=8166
Related
I am trying to do the simplest thing in the world: I want a node script to fetch the PUBLIC feed of a page.
I am trying with this:
var FB = require('fb' )
FB.api('/flourandfire/feed', 'get', function (res) {
if (!res || res.error) {
console.log(!res ? 'error occurred' : res.error)
return
}
console.log(res.id)
console.log(res.name)
})
And it's not working.
{ message: 'An access token is required to request this resource.',
type: 'OAuthException',
code: 104,
fbtrace_id: 'EiH31CMsyvh' }
So, I created an "app" by the same user who owns the page and tried:
var FB = require('fb', { appId: 'XXXXXXXXXXXXXXXXXXXXX', appSecret: 'YYYYYYYYYYYYYYYYYYYYY' })
FB.api('/flourandfire/feed', 'get', function (res) {
if (!res || res.error) {
console.log(!res ? 'error occurred' : res.error)
return
}
console.log(res.id)
console.log(res.name)That is, what's the EASIEST, most permanent way to get the right access token/appId/appSecret/whatever to plumb into these functions and make the call work?That is, what's the EASIEST, most permanent way to get the right access token/appId/appSecret/whatever to plumb into these functions and mThat is, what's the EASIEST, most permanent way to get the right access token/appId/appSecret/whatever to plumb into these functions and make the call work?ake the call work?That is, what's the EASIEST, most permanent way to get the right access token/appId/appSecret/whatever to plumb into these functions and make the call work?
})
Still nothing.
{ message: 'An access token is required to request this resource.',
type: 'OAuthException',
code: 104,
fbtrace_id: 'EiH31CMsyvh' }
I tried adding the access token for that app:
var FB = require('fb', { appId: 'XXXXXXXXXXXXXXXXXXXXX', appSecret: 'YYYYYYYYYYYYYYYYYYYYY' })
FB.api('/flourandfire/feed', 'get', { access_token: 'ZZZZZZZZZZZZZZZZZZZZ' }, function (res) {
if (!res || res.error) {
console.log(!res ? 'error occurred' : res.error)
return
}
console.log(res.id)
console.log(res.name)
})
Still nothing:
{ message: 'Invalid OAuth access token.',
type: 'OAuthException',
code: 190,
fbtrace_id: 'Hf8Gjudpwty' }
The feed is public.
So, how the HECK do I get this feed?
That is, what's the EASIEST, most permanent way to get the right access token/appId/appSecret/whatever to plumb into these functions and make the call work?
I´ve never used the fb package, but the docs tell me that this should work:
var FB = require('fb');
FB.options({appId: 'xxx', appSecret: 'xxx'});
FB.setAccessToken('APP-ID|APP-SECRET'); //btw, this is an "App Access Token". Maybe you do not even need this line if you specify the options correctly.
//FB.options({accessToken: 'APP-ID|APP-SECRET'}); //another way according to the docs
FB.api('/flourandfire/feed', (res) => {
if (!res || res.error) {
console.log(!res ? 'error occurred' : res.error);
return;
}
console.log(res);
});
Docs: https://www.npmjs.com/package/fb
More information about Tokens:
https://developers.facebook.com/docs/facebook-login/access-tokens/
http://www.devils-heaven.com/facebook-access-tokens/
I'm doing a hybrid app using Ionic framework.
I want to implement a facebook event system to attend some events. I have this:
ngFB.api(
'/666945880120392/attending',
'GET',
{},
function(response) {
// Insert your code here
}
);
and I have ngFB in my app.js file like this:
ngFB.init({appId: '[APP_ID]'});
The error I have is:
openfb.js:256 GET https://graph.facebook.comundefined/?access_token=undefined net::ERR_NAME_NOT_RESOLVED
I was looking for a solution but no answer. I also try in the developer facebook console and the answer is correct:
https://developers.facebook.com/tools/explorer/145634995501895/?method=GET&path=666945880120392%2Fattending&version=v2.7
What it's happening? Thanks!
EDIT 1
Thanks to #e666 I did now this
ngFB.api({
method: 'GET',
path: '/666945880120392/attending'
}).then(function(response) {
console.log(response);
}).catch(function(error) {
console.error(error);
});
And the error now is that if I'm logged with an account always the return in the event is:
Object {data: Array[1], paging: Object}
And inside data is the name of another person, the unique person that is attending to the event and no the person who is logged with the access token.
Thanks!
EDIT 2
I opened another question because this is not the result than I hope, I need to go to an event, no to get the list of the people that goes to the event.
I have this now:
ngFB.api(
"/666945880120392/attending",
function (response) {
if (response && !response.error) {
console.dir(response);
}
}
);
the access_token is ok, and the response is
openfb.js:256 GET https://graph.facebook.comundefined/?access_token=EAABlK6y7pOUBAN3CPWdZB5FL…LCpXL9Bd3ELHQZAA6EJc6cCheAxUUnL59ZCZAf7aROCapJxiu991fxjDkxmMO651rfuREwZDZD net::ERR_NAME_NOT_RESOLVED
In the page of facebook https://developers.facebook.com/tools/explorer/?method=POST&path=666945880120392%2Fattending&version=v2.5
The response is
{
"error": {
"message": "(#299) Requires extended permission: rsvp_event",
"type": "OAuthException",
"code": 299,
"fbtrace_id": "G7HFJ48pbkx"
}
}
But I have this permission. Can someone help me please?
First, the path is undefined because you don't use correctly the method api. That is how you need to use it :
ngFB.api({
method: 'GET',
path: '/666945880120392/attending'
}).then(function(response) {
console.log(response);
}).catch(function(error) {
console.error(error);
});
Furthermore, you have undefined in access_token. As I looked in the library code, I am not sure that you can use this library without login as a user to have an access_token.
To have an access_token you need to use this function :
ngFB.login({scope: 'email'}).then(function(response) {
console.log('Access token' + response.authResponse.accessToken);
}).catch(function(error) {
console.error(error);
});
The access_token will then be automatically attached to request that you make with OpenFB.
You can find more complete examples of how to use the library is the github here : https://github.com/ccoenraets/OpenFB/blob/master/indexng.html
I am developing a facebook app where I need impersonation of users, so there is an option when you use facebook for "Use Facebook As", i need to implement the same in my app.
I see the access tokens retrieved for the pages I own, but I don't understand how to use this with the following graph api to post
var body = 'Reading JS SDK documentation';
FB.api('/me/feed', 'post', { message: body }, function (response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Post ID: ' + response.id);
}
});
so my question is how do I set the access token for the api in this case??
I Hope, am clear with my question
Add it with the parameters. Change this line
FB.api('/me/feed', 'post', { message: body }, function (response) {
to...
var my_token = "the access token value";
FB.api('/me/feed', 'post', { message: body, access_token : my_token }, function (response) {
Getting an OAuth error doing a FB.api('/me/photos', 'post') on HTTPS, but works fine on HTTP.
Error occured:{"message":"An unknown error has occurred.","type":"OAuthException","code":1}
upload works:
http://sephoraframeworkapp.com
upload fails:
https://sephoraframeworkapp.com
CLICKING "FINISH" ON STEP4 does a call to FB.api('/me/photos','post'...etc) in order to POST a photo to the user's FB.
HTTP works FINE. however HTTPS FAILS!
FB.api('/photos', 'post', {
message: 'Use the Sephora Framework app to transform pictures from your life into one extraordinary story. http://seph.me/SmcbkM',
url: imgURL
}, function (response) {
if (!response || response.error) {
alert('Error occured:' + JSON.stringify(response.error));
} else {
FB.api('/'+response.id, function(response){
storeSubmission(response.images[1].source);
});
}
});
PLEASE HELP!
I am trying to call Yammer REST API for getting authenticated user's information using the following code:
$(document).ready(function() {
$.ajax({
method: "GET",
url: "https://www.yammer.com/api/v1/users/current.json",
contentType: "application/json; charset=utf-8",
dataType: 'json',
success: function(data) {
if (data.Success) {
alert(data);
}
},
error: function(xhr2, status2) {
alert(xhr2.status);
}
});
});
However, it is always going to error method. Can anyone guide me to proceed on this piece?
You're not sending the API any authentication information, so how does it know what user it's supposed to be pulling down? You should take a look at the Javascript SDK.
I had the same problem. Change url from "https://www.yammer.com/api/v1/users/current.json" to "users/current.json" solves the issue (it will be going to success method)