Appcelerator Titanium: Facebook Graph API empty Friends list - javascript

another problem with the Facebook connection from Titanium.
I make an request to Facebook with Graph API, but I only get an empty result:
SUCCESS; {"data":[]}
This is my code:
Ti.App.fb.requestWithGraphPath('me/friends', false, 'GET', showRequestResult);
I've also tried to use the request example from KitchenSink, but that's not working, because the method is turned for my FB SDK.
So, I've tried to update the permissions for facebook with "user_friends" but if I log in, it's not asking for this permission.
Any Ideas?
Thanks for your help.

The reason why it doesn't work was that i have to get the Facebook permission "user_friends".

Related

How to get the posts of the news feed with graph api javascript

I want to get my Facebook news feed in order to filter depending on some options.
But when I ask for permission as below, read_stream is not accepted, I 'm getting "Invalid Scopes: read_stream"
FB.login(checkLoginStatus, {scope:'read_stream,email,publish_actions, user_friends, user_posts '});
Looking around in Internet, I found out that this permission has to be required from Facebook.
Any workaround for that would be much appreciated.
The permission read_stream was deprecated with v2.4. You wouldn't have gotten it granted during Login Review anyway.
Basically, /{user_id}/home endpoint with the newsfeed is no longer accessible. If you want to use /{user_id}/feed, that should work, but this only contains the user's own timeline.
See
https://developers.facebook.com/docs/apps/changelog#v2_4
https://developers.facebook.com/docs/graph-api/reference/v2.4/user/home/
https://developers.facebook.com/docs/graph-api/reference/v2.4/user/feed

Can't post to FB using Koala (Graph API)

I'm attempting to post to a Facebook group using the Koala Gem.
I am the administrator of the group. I log in using Facebook Javascript SDK.
Before posting, I check permissions and have "publish_actions".
However, when posting I still get a 200 message ("message: (#200) Insufficient permission to post to target on behalf of the viewer [HTTP 403]):")
I've been struggling with this for a couple days. Can anyone provide me with some insight?
Below is the code I'm using for permissions and to post.
graph = Koala::Facebook::API.new(current_user.fb_token)
permissions = graph.get_connections('me','permissions')</code>
The array contains {"permission"=>"publish_actions"}
graph = Koala::Facebook::API.new(current_user.fb_token)
message = "#{#group.name} - #{#message.message} - #{advertisement.message}"
graph.put_connection("#{fb_group_id}", "feed", message: message)
Should have updated awhile ago; forgot I left this.
The code was correct. It's an API restriction. Unfortunately it will work in a development (test) account, but won't work in a production account.

Is there any way to delete photos with the Instagram API?

I tried doing a DELETE request to /media/{id} in the API console on their website, after authenticating with my own account and finding a photo id, but it said 405 METHOD NOT ALLOWED. Plus there are obviously built in requests for deleting comments, likes, etc.
Is there a workaround for this, or is it hopeless?
There is no API endpoint for delete media and there is not plan to add in near future
Reference : https://developers.facebook.com/docs/instagram-api/reference/ig-user/media#updating
Thanks

How to get twitter oAuth token of a logged in user

I'm trying to set up a javascript function to post a status to a twitter account using POST statuses/update, details here: https://dev.twitter.com/docs/api/1/post/statuses/update. The goal is a Twitter post similar to the open graph actions on Facebook.
I'm using jQuery ajax to make the post request, here's what I have so far:
$.ajax
({
type: "POST",
url: "https://api.twitter.com/1/statuses/update.json",
headers: jsonData,
data: {},
dataType: "jsonp",
success: function( data )
{
}
});
I believe that I need to generate a header something like this for security:
Authorization: OAuth oauth_consumer_key=consumerKey, oauth_nonce=nonce,
oauth_signature=signature, oauth_signature_method="HMAC-SHA1",
oauth_timestamp=timestamp, oauth_token=userToken, oauth_version="1.0"
I have the consumer key for my app, I can generate a nonce, I'm generating the signature and timestamp using the methods from this question Twitter OAuth authentication in javascript. The only thing I have left is th oauth_token, which I believe is the token of the user whose feed I wish to post to. Please correct me if I'm wrong about that.
The problem is, I have absolutely no idea how to get this token from the user in order to post to their feed. I've spent the last 2 hours running around in circles through Twitter's oAuth documention without finding anything that looked useful; everything I've found was either flowcharts with no code examples or predicated on my code already having the user's oAuth token.
My question is this: how can I get the logged in user's oAuth token using javascript?
If that is not possible, I have another page where I am currently storing the user's twitter id in the database with their permission, getting their token and databasing it in PHP would also be satisfactory, assuming it doesn't change very frequently.
In order to obtain the oauth_token you need to follow the authentication process. Your application needs to be authorized to act on the behalf of the user.
I would recomend to take some time first and learn how OAuth exactly works (there is a lot of information available) and then implement it in your app. (http://hueniverse.com/oauth/)
You could also benefit from a library which will make your life easier. (in your case, look at: https://dev.twitter.com/docs/twitter-libraries#php).
Hope this has been useful.
Here is example for get twitter oauth token and post tweet in twitter .
Code sample is in php .
http://www.phpgang.com/how-to-post-tweet-on-twitter-with-php_414.html
1) to obtain the oauth token you need to follow the authentication process.
2) and your application needs to be authorized to act on the behalf of the user.
you can also see this twitter example for better understanding how it works
In this use can see the process of authorized user and post and get json result.
https://dev.twitter.com/rest/tools/console
I hope this will help you.
thanks

Facebook Feed Dialog: Post not showing up on friend's wall even though I get a response id

I am creating an app on facebook and I am trying to post to a friend's wall. I'm using the facebook javascript SDK and the FB.ui method to do this. In short here is my code:
function test() {
var obj = {
method: 'feed',
to: '######'
};
function callback(response) {
alert(response['post_id']);
}
FB.ui(obj, callback);
}
Note that I made this code very simple for testing purposes.
When I run it, a facebook feed dialog opens correctly and at the top says "Post Story to friendsname's Wall". I type in a message and press Share. My alert pops up with a response['post_id'] number. Because there is a response['post_id'] the story should've been posted successfully right? However when I navigate to the friend's wall there is no story. I've tried this multiple times in slightly different ways and haven't been able to get it to work. If I remove the 'to' parameter and simply post to my own wall it -does- work. So for some reason, posting to a friend's wall breaks it?
I know it's a rather broad question but I was wondering if anybody had any ideas why this doesn't work. Thanks
I suspect the problem may be because your application is in sandbox mode - https://developers.facebook.com/docs/ApplicationSecurity/
When testing your apps, place them into Sandbox Mode. This hides your
app entirely from all users who you have not authorized in the
developer app to see the app, for the roles described below. Please
note that when your app is in Sandbox Mode, you cannot call any API
calls on behalf of users who cannot see your app.
Basically, if your application is in sandbox mode, nothing your application does can be seen by users who have not authorized your application or by users that have not been specifically listed in the "roles" within your applications settings.
Remove you application from sandbox mode or add some users to specific "roles" within your application.

Categories

Resources