facebook messenger api “(#100) No matching user found” - facebook

im using facebook sdk and i keep getting an error message “(#100) No matching user found” and i followed the instruction on facebook documentation but i keep getting this message i already check the user id who i want to send it to also i used already an static id for this to check if im getting the wrong id from senders conversation api. i don't know if this is a bug or am i doing it wrong, i already added messenger product on my app
FB.api('/'+id+'/conversations?access_token=' + token + '&fields=senders','GET',function(conversations){
FB.api('/'+id+'/messages?access_token=' + token ,'POST',{
'recipient' : {'id' : conversations.data[0].senders.data[0].name},
'message' : {'text' :'hello ' + conversations.data[0].senders.data[0].name},
},function(messages){
console.log(messages);
});
});
});

Related

Error while subscribing page to Facebook App - Code 200 (Insufficient Permission)

I'm attempting to set up a way to retrieve Facebook Lead Ads as per instructions given here: https://developers.facebook.com/docs/marketing-api/guides/lead-ads/retrieving/
However on subscribing a page to the App, I'm getting the following error on printing the response:
code: 200
error_subcode: 1373034
error_user_msg: "You do not have the necessary permission for the
specified Page to perform the requested action."
error_user_title: "Insufficient Permission"
fbtrace_id: "CLbnoml6VX1"
is_transient: false
message: "Permissions error"
type: "OAuthException"
Here is the segment of code used to subscribe the app:
function subscribeApp(page_id, page_access_token) {
console.log('Page Access Token:'+page_access_token);
console.log('Subscribed Page to FB Leads Live Update. Page ID: ' + page_id);
FB.api('/' + page_id + '/subscribed_apps',
'post',
{access_token: page_access_token, subscribed_fields: 'leadgen'},
function(response)
{console.log('Successfully subscribed page', response);
});
}
I suspect that the page being subscribed is in question here (as the error states), and must be set accordingly to be subscribed to my app. I should state that the page is already subscribed to another app, and I'm using this page for testing purposes on my second FB App for another web application. Any insight would be appreciated!
Same situation.
Your assumption is correct. You can't have 2 apps attached to capture leads.
Once the other app is disconnected and enough time has passed (No explanation of how long), permissions will be set correctly

Facebook API v2.4 : How to get email id of FB user in cordova fb plugin

I'm using " com.phonegap.plugins.facebookconnect " Cordova plugin for FB login in my Phonegap app. My Facebook app is v2.4 . I'm getting only full name and id as login response.But I need email id of user to complete my login process on app.
But when i'm login with same fb credential in my old app i got all details of user as response.This app is connect with facebook app v2.3
Is there any way to get email id of fb user on login ?
My code :
$cordovaFacebook.login(["public_profile", "email", "user_friends"])
.then(function(success) {
//success
}, function (error) {
//error
});
$cordovaFacebook.api("me", ["public_profile"])
.then(function(success) {
//success
} }, function (error) {
//error
});
Thanks in advance
Search for "Declarative Fields" in the changelog: https://developers.facebook.com/docs/apps/changelog#v2_4
You now have to define the fields you want to get in the API calls. The basic call for the /me endpoint would be like this: /me?fields=name,email

HWIOAuthBundle, how to manually authenticate User with a Facebook access token?

I have a website (Symfony2) with HWIOauthBundle used to connect with Facebook and everything works fine.
Now, I'm trying to build an iOS app with Cordova and Ionic framework (AngularJS) and I want to authenticate my user with Facebook :
With $cordovaFacebook, I authenticate my user and get a valid Facebook access token, that's ok
I try to use this access token to authenticate my user on the server-side with HWIOauthBundle :
GET http://..../login/facebook?code=MY_FACEBOOK_ACCESS_TOKEN
Symfony rejects my request with this log :
INFO - Matched route "facebook_login" (parameters: "_route": "facebook_login")
INFO - Authentication request failed: OAuth error: "Invalid verification code format."
So my question is : how can I authenticate my user on both front and back end with Facebook connect?
Thanks :)
I've also been wondering how to implement a server side login with the HWIOAuthBundle.
I didn't find any solution on the web, so I coded the functionnality based on hints I've read on the net.
Basically, you have to :
authenticate the user on your app
make an http request to your server with the Facebook token.
ont the server side, check if the token is for your Facebook app, and retrieve the user's Facebook ID.
Get your user from the DB based on the fetched ID.
Here's my Symfony controller:
public function getSecurityFbAction($token)
{
// Get the token's FB app info.
#$tokenAppResp = file_get_contents('https://graph.facebook.com/app/?access_token='.$token);
if (!$tokenAppResp) {
throw new AccessDeniedHttpException('Bad credentials.');
}
// Make sure it's the correct app.
$tokenApp = json_decode($tokenAppResp, true);
if (!$tokenApp || !isset($tokenApp['id']) || $tokenApp['id'] != $this->container->getParameter('oauth.facebook.id')) {
throw new AccessDeniedHttpException('Bad credentials.');
}
// Get the token's FB user info.
#$tokenUserResp = file_get_contents('https://graph.facebook.com/me/?access_token='.$token);
if (!$tokenUserResp) {
throw new AccessDeniedHttpException('Bad credentials.');
}
// Try to fetch user by it's token ID, create it otherwise.
$tokenUser = json_decode($tokenUserResp, true);
if (!$tokenUser || !isset($tokenUser['id'])) {
throw new AccessDeniedHttpException('Bad credentials.');
}
$userManager = $this->get('fos_user.user_manager');
$user = $userManager->findUserBy(array('facebookId' => $tokenUser['id']));
if (!$user) {
// Create user and store its facebookID.
}
// Return the user's JSON web token for future app<->server communications.
}
I throw the Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException exceptions to handle login errors on my app.
Of course, you really should use https because you will be exchanging sensible information.
I don't know if it's the best way to do it but it works well.
Hope it helps !
Well, I think that Symfony doesn't actually reject your request. Facebook is. I'm not sure if this might help, but I know that a bunch a problems can happen when dealing with the Facebook Auth :
Do you know if the tool sends, along with the code parameter, a redirect_uri parameter ? If so :
Did you check that your redirect_uri HAS a trailing slash at the end ? See this
Silly question, but did you check that your app_id is the same when you got authorized via Cordova ?
Check that your redirect_uri DOES NOT have any query parameter.
Check that the redirect_uri that you use during the whole process is the same all the time.
Overall, it seems that your issue is almost all the time related to the redirect_uri URI format.

Not able to fetch the data for G+ using gigya

We have created the gigya account. Using the same gigya account we have created the Twitter, facebook & G+ account(Reference : http://developers.gigya.com/010_Developer_Guide/82_Socialize_Setup/005_Opening_External_Applications/16_Google).
We are able to get the user & there friends info using gigya for FB & Twitter, however we are not able to get the users and there friends info using gigya for G+ account.
We have checked that G+ account set properly(As we are able to get the G+ account info using G+ API).
Can anyone help us to resolve the issue(why we are not able to fetch the data for G+ account)
Code Snippet :
GSRequest request = new GSRequest(apiKey, secretKey,
"socialize.getFriendsInfo", false);
request.setParam(Parameters.uid, uid);
request.setParam(Parameters.format, "json");
GSResponse response = request.send(timeout);
String response_json = response.getResponseText();
System.out.println("Friends Info : ");
System.out.println("#### "+response_json);
Output :
Friends Info : Getting an blank friend list array ...
{ "friends": [], "oldestDataUpdatedTimestamp": 0, "oldestDataAge": 3417602649, "statusCode": 200, "errorCode": 0, "statusReason": "OK", "callId": "d383b76ff5ab4822899577f9cd15f3ea"}
Similarly for profile details : Not getting basic details like nickname & other attributes...
Thank you in advanced
On the Gigya API key you are testing with, in the Gigya Console to to the Settings >> Permissions screen and make sure to check the "Enable extended social functionality (including access to Google+ circles)" permission. Then try logging back in again using the showLoginUI with the G+ user you are calling getFriendsInfo for. The next time you call getFriendsInfo it should return the friends information.
If that still doesn't work, try it with a new G+ user who hasn't signed into that API key before.

Publishing on Facebook user's wall

i am developing an appon blackberry platform in which i hve to publish a message on users wall...i am able to get session id...but dont know how to proceed further...
i am doing something like this...
enter code here
URLEncodedPostData post = new URLEncodedPostData(URLEncodedPostData.DEFAULT_CHARSET, false);
post.append("method", "stream.publish");
post.append("message", "published through the Facebook API");
post.append("session_key", sessionKey);
post.append("attachment", null);
post.append("action_links", null);
post.append("target_id ", null);
post.append("uid ", null);
i am sending this as post data to following url :
http://api.facebook.com/restserver.php?
and the response i am getting contains :
101
Invalid API key
You should try to register your application, get API key and use in in requests.
Register and go www.facebook.com/developers/createapp.php