Twitter API geo - twitterapi-python

I am really new to this and I am trying to use Twitter's API to get geo information. It seems pretty straight forward. Enter Latitude/Longitude and the distance to search from this point in either mi. or km but I don't know how/where I am supposed to enter my API key or what format/order it is supposed to be in; where it is supposed to be located, etc... here is sample:
https://api.twitter.com/1.1/search/tweets.json?q=%20&geocode=37.781157%2C-122.398720%2C10mi
so where do I put my credentials and in what order etc... I just can't find any info.
As always, all help is greatly appreciated...

You can't submit credentials via a URL. With python you can use this library:
TwitterAPI
from TwitterAPI import TwitterAPI
SEARCH_TERM = 'pizza'
GEOCODE = '37.781157,-122.398720,10mi'
api = TwitterAPI(<consumer key>, <consumer secret>, <access token key>, <access token secret>)
r = api.request('search/tweets', {'q':SEARCH_TERM, 'geocode':GEOCODE})
for item in r:
print(item['text'] if 'text' in item else item)

Related

How to get the coordinates from the address using google map

I'm trying to get the coordinates from the address which user input,using flutter_google_places but here is gives me error
{candidates: [], error_message: You must use an API key to authenticate each request to Google Maps Platform APIs. For additional information, please refer to http://g.co/dev/maps-no-account, status: REQUEST_DENIED}
here is my code
static Future<String> getPlaceId(String input) async {
final String url =
"https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=$input&inputtype=textquery&key$googleApiKey";
var response = await http.get(Uri.parse(url));
Map<String, dynamic> json = jsonDecode(response.body);
print(json);
var placeId = json['candidates'][0]['place_id'] as String;
return placeId;
}
i added the key too, but it gives me this error, please help how to do this or this is there any other to get the coordinates from user input address.
There are a few steps you have to make sure you complete. First, make sure your API key is not restricted for your device. You can either set the key to restrict none or just add your authentic key to the API key. And get the access.
Also basic stuff. Make sure all the needed SDK's are activated for your project. And It would be better if you can provide some more data. That would be kinda helpful. Also don't forget to add your api key to the xml file inside your android project. if you're doing it for android.
(BTW the issue is with your credentials. First solve that. Then you can find the way to get the coordinates. It's pretty easy. You're already there.)

[orientdb]: get the current user when authenticating with tokens

How can i get the rid of the current user (OUser) via the binary api. I am using the inbuilt token based authentication.
I would expect two approaches:
a function like currentUserRID() or something. I looked in the documentation but found nothing.
decrypting the token to unlock the userId/name. I tried this approach but couldn't manage to. I looked here: https://github.com/orientechnologies/orientdb/issues/2229 and also https://groups.google.com/forum/#!topic/orient-database/6sUfSAd4LXo
I find your post just now, may be is too late but you can do like this:
OServer server = OServerMain.create(); // for exemple
ODatabaseDocumentTx db = new ODatabaseDocumentTx(BDDURL).open("admin","admin"); // admin is juste for this exemple
OTokenHandlerImpl handler = new OTokenHandlerImpl(server);
OToken tok = handler.parseWebToken(yourtoken);
OUser user = tok.getUser(db);

Rails 3.1 - Facebook Page API calls

I have the following working perfectly for calls to Facebook pages with simple URLS like: www.facebook.com/TurbonegroHQ
def get_facebook
#artist = Artist.accessible_by(current_ability).find(params[:id])
if #artist.facebook_url.present?
require 'open-uri'
require 'json'
result = JSON.parse(open("https://graph.facebook.com/"<<#artist.facebook_url).read)
#hometown = result["hometown"]
#band_members = result["band_members"]
#likes = result["likes"]
end
end
However, when a Facebook page URL isn't in this format, but something like https://www.facebook.com/pages/Clutch-The-Bakerton-Group-Weathermaker-Music/16637738637 it fails. Any ideas how I can get around this?
Thanks in advance?
TurbonegroHQ is the username of the page - this is interchangeable with the object ID in the Graph API.
If the page doesn't have a username you need to access it via the ID instead. In that case https://graph.facebook.com/16637738637 is the URL to access
Usually you'll have IDs rather than the URLs as the ID is returned in the API on all the endpoints I can think of

How to make a Facebook search request to find Locations

I use Facebook C# SDK. I try to make a Facebook search request to retrieve locations without success.
I don't know all the parameters which can be used in a "search" request.
I use this code:
Dictionary<string,object> searchParams = new Dictionary<string,object>();
searchParams.Add("q", "Orange");
searchParams.Add("type", "place");
searchParams.Add("country", "France");
FacebookClient fbClient = new FacebookClient(token);
var searchedPlaces = fbClient.Get("/search", searchParams);
I receive a response with some places everywhere in the world not only in France!!
The filters "category" and "country" have no effect.
Which parameters can be used in the request ? Where find the parameters list for a search request?
How to fix parameters "category", "country" and what write in the parameter "q"?
From the Documentation:
The example search for places is given as https://graph.facebook.com/search?q=coffee&type=place&center=37.76,122.427&distance=1000 - you'll need an access token but otherwise that works fine for me; the response shows Coffee shops centered around those coordinates
{edit}
The only search options are
q for a text based query
center (with coordinates) and distance to specify the approximate location
Both of the above

Facebook - obtain location /places ID via location name

I'm able to return a location's details by sending a query via the graph api with the location's ID, however I'm looking to achieve the reverse - effectively find location id by sending a request containing the location name (city, state etc). Is this possible?
This is possible under a few different approaches. You can either search using long / lat positions and put the place name into the query. This search will search places only.
Do the following
https://graph.facebook.com/search?q=ritual&type=place&center=37.76,-122.427&distance=1000&access_token=mytoken.
This will return ritual coffee.
Another way is to search through facebook pages using the following
https://graph.facebook.com/search?q=ritual%20coffee&type=page&access_token=mytoken
This way is more difficult as you will obviously need to parse the list in more detail.
You also can use the place sdk from facebook:
compile group: 'com.facebook.android', name: 'facebook-places', version: '4.30.0' // For latest version, see https://developers.facebook.com/docs/android/
and then:
PlaceSearchRequestParams.Builder builder = new PlaceSearchRequestParams.Builder();
builder.setSearchText("Cafe");
builder.setDistance(1000); // 1,000 meter maximum distance.
builder.setLimit(10);
builder.addField(PlaceFields.ID);
GraphRequest request = PlaceManager.newPlaceSearchRequestForLocation(builder.build());
request.setCallback(new GraphRequest.Callback() {
#Override
public void onCompleted(GraphResponse response) {
// Handle the response. The returned ID in JSON is the placeId.
}
request.executeAsync();
If I understand your question correctly you can use fql:
https://api.facebook.com/method/fql.query?query=QUERY
where query should be something like this:
select page_id from place where name = ;
Here is a page for your refrence:
http://developers.facebook.com/docs/reference/fql/place/