Graph API: get nearby places - facebook

Is there a way to pass in lat/long and get a list of nearby places using Graph API 2.1?
Was looking to allow a user to check in from an iOS app, but I'd like to provide a list of nearby places so that I know which place ID to pass into the feed end point.
https://developers.facebook.com/docs/graph-api/reference/v2.1/user/feed/

Yes, this is possible if you can get the lat/lng coordinate from your device. Have a look at https://developers.facebook.com/docs/graph-api/using-graph-api/#search
GET /search?q={query}&type=place&center={lat},{lng}&distance={distance}
You can leave the {query} blank if you don't want to narrow down your results
All Graph API search queries require an access token included in the request.

If you want to make a request to the Facebook Graph API for location searches, you do not need a user Access Token, you can use your App Token, which you'll find here: https://developers.facebook.com/apps/{app_id}/settings/advanced under Client Token
Assuming you have the facebook SDK setup correctly, all you have to do is add your App Token to your info.plist under the key FacebookClientToken. Now you should be able to make Graph Location API requests without authorizing a user!
This is what your info.plist should look like:
<key>FacebookAppID</key>
<string>{{APP_ID}}</string>
<key>FacebookClientToken</key>
<string>{{CLIENT_TOKEN}}</string>
<key>FacebookDisplayName</key>
<string>{{APP_NAME}}</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
Obviously, change anything between the {{ }} to the appropriate value.

Related

Twitter Call back URL

I am working with twitter SDK to integrate with in ios app.When i follow all the step and create the customer key and put it in my app.When I run the app it show
"[TwitterKit] did encounter error with message
"Error obtaining user auth token.": Error Domain=TWTRLogInErrorDomain
Code=-1 "Callback URL not approved for this client application.
Approved callback URLs can be adjusted in your application
settings" UserInfo={NSLocalizedDescription=Callback URL
not approved for this client application. Approved callback URLs can
be adjusted in your application settings"
How to resolve this?
I had the same problem and the TwitterKit documentation is not accurate or Twitter has changed their policies. In any case, on the Twitter Apps site, the callback URL has to be set very specifically. The callback URL should be in the format:
twitterkit-{consumer/api key}://
For example:
twitterkit-128238aKjqlp123AKdasdf://
Also, this needs to be registered in your Info.plist exactly the same:
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>twitterkit-128238aKjqlp123AKdasdf</string>
</array>
</dict>
More documentation is listed here: https://developer.twitter.com/en/docs/basics/callback_url.html
I just added on callback url field twitterkit-<api/consumer Key>://.
If you have an apiKey like abc you should add twitterkit-abc://. This work for iOS, for Android just add twittersdk://.
To Fix this issue do as below:
[Mandatory]
Add CallbackURL into the dashboard as below format:
For iOS:
twitterkit-CONSUMERKEY://
For Android:
twittersdk://
Help Link:
https://twittercommunity.com/t/ios-twitter-login-error-code-415/107775
[ Note: Please replace your consumer key in place of words "CONSUMERKEY" in above format]
My solution: I hope it's useful.
Go to https://apps.twitter.com
Then in the "Settings" tab of your app.
Fill the "Callback URLs" form.
According to this documentation i guess you just have to enter a valid URL :
https://github.com/twitter/twitter-kit-ios/wiki/Installation
NOTE: Although the callback URL will not be requested by Twitter Kit in your app, it must be set to a valid URL for the app to work with the SDK.
Hey everyone here is a simple fix that worked for me.
Go to: https://apps.twitter.com
Go into the settings tab.
Under Terms of Service URL uncheck the box that says:
"Unable Callback Locking"
Now test your app.
Finally I found the solution for my case. Hope it'll help someone else
Put this in URL Callback field.
twittersdk://
Refer: https://github.com/twitter/twitter-kit-android/issues/135

Generate access token Instagram API, without having to log in?

So I am building a restaurant app and one of the features I want is to allow a user of the app to see photos from a particular restaurant's Instagram account.
And I want a user to be able to see this without having to login to their Instagram account, so they shouldn't even need an Instagram account for this to work.
So I have read this answer How can I get a user's media from Instagram without authenticating as a user?
And I tried what it said and used the client_id(which I recieved when I registered my app using my personal Instagram account), but I still get an error back saying :
{
meta: {
error_type: "OAuthAccessTokenException",
code: 400,
error_message: "The access_token provided is invalid."
}
}
The endpoint I am trying to hit is :
https://api.instagram.com/v1/users/search?q=[USERNAME]&client_id=[CLIENT ID]
So do I absolutely need an access token for this to work(and thus have to enforce a user to log in) ?
If I do, then is there way to generate an access token somehow without forcing the user log in?
I believe there is a way around this, as the popular dating app Tinder has this desired functionality I am looking for, as it allows you to see photos from people's Instagram account without having to log in! (I have just verified this 5 minutes ago!)
Any help on this would be much appreciated.
Thanks.
Edit April 2018: After facebook privacy case this endpoint is immediately put out of service. It seems we need to parse the JSON embedded in <script> tag directly within the profile page:
<script type="text/javascript">window._sharedData = {"activity_counts":...
Any better ideas are welcome.
You can use the most recent link
GET https://www.instagram.com/{username}/?__a=1
to get latest 20 posts in JSON format. Hope you put this to good use.
edit: other ways aren't valid anymore:
https://www.instagram.com/{username}/media/
Instagram used to allow most API requests with just client_id and without access_token, the apps registered back in the day still work with way, thats how some apps are able to show instagram photos without user login.
Instagram has changes the API specification, so new apps will have to get access_token, older apps will have to change before June 2016.
One way you can work around this is by using access_token generated by your account to access photos. Login locally and get access_token, use this for all API calls, it should not change, unless u change password,if it expires, regenerate and update in your server.
Since the endpoints don't exist anymore I switched to a PHP library -
https://github.com/pgrimaud/instagram-user-feed
Installed this lib with composer:
composer require pgrimaud/instagram-user-feed "^4.0"
To get a feed object -
$cache = new Instagram\Storage\CacheManager();
$api = new Instagram\Api($cache);
$api->setUserName('myvetbox');
$feed = $api->getFeed();
Example of how to use that object -
foreach ($feed->medias as $key => $value) {
echo '<li><img src="'.$value->thumbnailSrc.'"></li>';
}

how to get user's posts & updates from Google plus like facebook

I want to get all wall updates of user's google plus account like facebook.
I have seen official link for it which is
Google Plus Documentation for iOS
& I have downloaded sample from there which is here Google Plus SDK Sample
it works well for getting user's information like email id,profile name,user's friend list with images & for posting on google plus.
but I am not getting user's post & updates.
all I want is user's wall updates & user's friends updates from google plus like facebook does.
but from above link i have found nothing for getting wall updates.
I have searched google for this also & get nothing regarding above problem.
any help for above problem appreciated.
Thanks in advance
From a backend server you can easily perform this API call to read a user's public activities. You can see the REST API here:
https://developers.google.com/apis-explorer/#p/plus/v1/plus.activities.list
Combine this with a people.list and you can query for a user's friend activities on Google+.
On iOS, you probably don't want to make these API calls directly from a user's device. If you can, you should offload the work to a backend server to avoid overworking the mobile client. That said, you can perform an API query similar to listing people in circles:
GTLQueryPlus *query =
[GTLQueryPlus queryForActivitiesListWithUserId:#"me" collection:#"public"];
[[[GPPSignIn sharedInstance] plusService] executeQuery:query
completionHandler:^(GTLServiceTicket *ticket,
GTLPlusActivityFeed *actFeed,
NSError *error) {
}
If you put a breakpoint in the application on the function, the activities feed will be something like as follows:
(lldb) po actFeed
{
nextPageToken:"CAIQ44qZ58DgtwIgFCgB"
etag:""DOKFJGXi7L9ogpHc3dzouWOBEEg/UMVQXfw8ynZaTz31tpuZo473TsQ""
title:"Google+ List of Activities for Collection PUBLIC"
updated:"2013-07-16T04:04:34.697Z"
kind:"plus#activityFeed" items:[20]
}
The items array contains the actual activities that a user has publicly written on Google+.

In terms of privacy, is it acceptable to extract the user id from a Facebook share response to make use of that user's details?

Using the Facebook API, you can get back the post ID of a Facebook share, even if the user has not authorized your app.
The post ID is prefixed by your user ID, and separated by an underscore.
FB.ui({
method: 'feed',
name: 'People Argue Just to Win',
link: 'http://www.nytimes.com/2011/...',
}, function( response ){
// Response gives you :
// { post_id: "[fbUserId]_346759642059572" }
});
To me it looks like Facebook is using this programmatically, rather than with the idea of providing us the userId out of the kindness of their hearts. But it's extremely tempting to use.
I'm a little rusty on permissions - if there is a way to get back all the users that have liked/shared a specific URL, and not just a count, then this should be okay.
But the question remains, is it acceptable to use?
EDIT:
Now that I think about it, you can access the user ID by making an anonymous call to https://graph.facebook.com/[postId] but ONLY if the post was made public.
If you get a response from FB, it means that you have already ask the user for the required permissions,
so yes you can use the data returned from Facebook as you like, but you always have to inform the users how you use those data.
You can only cache user data if you have permission or it is necessary for the function of your app. Using the like button you can subscribe to edge.create and cache the response from the like.
refer to: http://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/
II. Storing and Using Data You Receive From Us
You will only request the data you need to operate your application.
You may cache data you receive through use of the Facebook API in
order to improve your application’s user experience, but you should
try to keep the data up to date. This permission does not give you any
rights to such data.
in my app i store the id of every page or user that is viewed to speed up page load times and count page views. Seems with in the scope of Policy as long as i am not sharing the info with 3rd parties or making public what a user has set to non public.

Facebook Graph API - get friends info

I'm trying to figure out how to get users friends information using either Graph API or FQL
Just for testing I would like to get my friends education_histroy.
To do that I created a test app, requested extended permissions using
scope=offline_access,manage_friendlists,friends_work_history,
friends_education_history,friends_about_me
and got access token to play with the API.
It works great when I query for current user using /me. But it returns nothing for my friends.
I was assuming that if I request, let's say friends_work_history, that extra field (work_history) will appear inside friend's object, when I query by friend's id:
https://graph.facebook.com/FRIEND_ID&access_token=TOKEN
But all I see is basic info about that user (friend).
Then I tried to request that field specifically:
https://graph.facebook.com/FRIEND_ID?fields=work&access_token=TOKEN
With no luck again. Returns just friend's id..
I tried to access that information with FQL:
https://api.facebook.com/method/fql.query?query=select+work_history+from+user+where+uid+in+(FRIEND_ID)&access_token=TOKEN
Returns work_history = TRUE instead of array. And that friend definitely has work history specified.
Can someone help me to understand how to get friends info using my app and extended permissions?
Graph API is the smart choice in most cases. To retrieve your friend information you need to collect some extended permissions from the user first. Then you can retrieve a lot more information other than the basic ones.
Following is a list of extended permissions related to friends different kind of information
friends_about_me
friends_activities
friends_birthday
friends_checkins
friends_education_history
friends_events
friends_games_activity
friends_groups
friends_hometown
friends_interests
friends_likes
friends_location
friends_notes
friends_online_presence
friends_photo_video_tags
friends_photos
friends_relationship_details
friends_relationships
friends_religion_politics
friends_status
friends_subscriptions
friends_videos
friends_website
friends_work_history
Hope it helps :)
I've been wrestling with this all day myself and I believe I have figured it out, nowhere in facebook documentation (that I have found) is this clear. And I don't believe the other answers actually answered your question, it looks like you requested permissions correctly. Anyway, to request the information you are looking for, ping the api like this:
https://graph.facebook.com/userid/friends?fields=work&access_token=ACCESSTOKENHERE
This will return you all the friends' info in one long JSON response.
It is a little confusing because the permissions you are asking for are not the same thing you need to query the API.
The query above will return the friends' ids with work history. You can add commas to the fields parameter to include additional info like name, but then the API calls/responses end up taking a long time.
http://developers.facebook.com/docs/reference/api/user/
you can get all the fields mentioned here .To get work you need to have user_work_history or friends_work_history permission
in the link it is mentioned what permissions to obtain before you get the info and another thing that user has to allow your application,this will make your app to get the informations.
From this answer to another question: a call to 'me/friends?fields=work' worked for me!
I'd suggest that you go to http://developers.facebook.com/docs/reference/api/user/ like most of the others are suggesting but as a general tip, use the friends_education_history as a way to get the friend's history.
P.S: Minor spelling error in your original question that should be edited. "education_histroy." = education_history
in the second line of your main paragraph.
You can use this code you will get name, profile picture, ID of your friends.
FB.api('/me/taggable_friends', function(response) {
for (var i = 0; i < friend_data.length; i++) {
results += ''+friend_data[i].name;
}
});
Before that in your developer account created app-> go to tools and support->graph API explorer-> click Get Token. In that window click user_tagged_places and click Get Access Token. You will get your friends list.