Query the Facebook Graph API for objects containing a given string - ios

I'm looking to get back photos from a specific album on Facebook that contain a given string in their title. Can this be done? The only alternative I know of would be to download ALL photos from the album (at the moment there's about 500 and this number will grow over time), parse them all and then eventually filter. That could become (and already kind of is) an extremely costly operation I'm looking to avoid.
I have looked all over and have yet to find anything somewhat related, so if there's an answer to this question already please link me to it, thanks!

You do have to go through the album, there is no Search API for that.
/album-id/photos
check for the string in the title
use paging to get the next batch of photos
repeat from number 2 until there is no next batch
You can also cache the ids/titles for later, so you don´t have to hit the API for a all the photos in a new search, but that´s completely up to you. There is no other way.

Related

How to get specific results using MediaWiki API in Rails backend?

I'm doing my final project for a coding school that will be a deep song search app that returns every detail about a song (composer, personnel on the track, lyrics, studio, media uses, images, etc). I'm using React frontend/Rails backend API. I'm new to API's and have tried Discogs and Musicbrainz but find the Mediawiki to be the easiest to traverse. Messing with their sandbox using Query, I feel like I'm getting closer but wondering if anyone with more experience out there could help me get precisely what I need.
I would like a music search to return a list of matches (could be same title but different songs or same title but different recordings). A user can click on the results to see the details. I would like the API to return links and hopefully images (album cover, etc). Does anyone know the best way to go about this?
I've also tried using the Ruby Gem wrapper Mediawikitory https://github.com/molybdenum-99/mediawiktory. I like the clean interface but can't quite find the right parameters.
The closest I've come to what I'm looking for in the Mediawiki sandbox is an example like this for the All Star (Smash Mouth):
https://en.wikipedia.org//w/api.php?action=query&format=json&prop=&list=search&continue=-%7C%7C&srsearch=star%20(song)&srlimit=5&sroffset=15&srqiprofile=engine_autoselect&srwhat=text&srinfo=totalhits%7Csuggestion%7Crewrittenquery&srinterwiki=1
This gives a list of songs (I'll have to concatenate '(song)' in every search unless there's a specific category parameter I don't know about).
So with further research I was able to drill down to specific song searches (and this will work for any thing this specific). You have to use srsearch and then search option in lists. So an example for a list of songs based on a given title:
https://en.wikipedia.org/w/api.php?action=query&formatversion=2&format=json&prop=info%7Cpageimages&generator=search&inprop=url&piprop=thumbnail%7Cname&gsrsearch=I%20love%20you%20(song)&gsrwhat=text
Make sure you choose version 2 as it gives you a better formatted Object to map over.
The Mediawiki API is very robust. You just have to spend a little time with it. The sandbox is great.

Facebook Search in Graph API

I'm developing an iOS application that let the user to search for a person throught the Graph API.
What I want is the SAME behavior that it's present on the Facebook website. You know when you begin to search for a person in the top text input? The first results will be mostly your friends AND some people you MAY know or people you already looked for.
The problem? Try to use the same search pattern here to search a person: Graph Api Explorer
The Graph Api returns DIFFERENT results than the search input on the Facebook website.
Does anyone knows why? Is there a way to achieve the same results?
Facebook are using many algorithms to display search result like Relevance Indicators, Complexities of User-Centric Search and The Product.
One of the algorithm to display result on their page as below.
Personal Context:
Unlike most search engines, every Facebook search involves two key elements - a query and a querier.
Just as we need to understand the query, it’s as essential to understand the person behind the query.
People are more likely to be looking for things located in their own city/country or for people who share the same college/workplace.
We consider this information and much more when ranking results. The more we know about you, the better your search results will be.
In Graph API, they are not using this algorithm.They are just displaying the queried result. Hence you can not achieve same result using graph search API.
To achieve this you can use following apporach -
Get the friend list of user using me/friends?limit=1&offset=1
Get the user list using search api
merge both the result
show result(s) to user
For more information(approach/algorithm) you can check Intro to Facebook Search
Is there a way to achieve the same results? - NO
Does anyone knows why? - NOT REALLY
(Edit: Seems in another answer, someone does actually, but it doesn't change the answer for "If you can achieve it")
But its safe to presume that Facebook does not allow all functionality through the API, why would they after all ? They need to keep the people coming to their own platform. So I can't give you a straight forward response on WHY, but IF ? Not possible, there is zero documentation about more specified search for type user. When you request user friends, you will only get the user friends who are using the same app starting v2.0
Am afraid that you will have to drop the functionality you want to achieve.
It is not just the graph search. When you refresh your TimeLine. The order of posts gets changed every time because Facebook takes a Pull on Demand approach. Which means whenever you login, the data from your friends is fetched. Which is why facebook has a limit to maximum number of friends.
Talking about the Graph search and Graph API. They are not same and the Graph Search cannot be accessed through the Graph API. So, you would have to change your approach.
To explain why the graph search gives different results on same search term. I would guess that it follows the game Pull on Demand model ( although it is not open and we cannot know for sure ). Following that model makes sense though.
Thanks

Twitter Search Tweets API - Different Users But Returns Same Tweets

I'm trying to create images streams from social media hashtag.
When i try to using Twitter, there's a problem when getting tweets images. I already succeed displaying the images but there's a lot of duplicate tweets! The reason is there's a few users who tweet same tweet, and i think they all are bot because when i stalk their profile they all got same tweets.
Here is the example :
http://t.co/NMX3B68eBT http://t.co/xDeBSS7GRr http://t.co/VmmNezY8Qg
Here is the query :
$response = $twitter->get('search/tweets.json?q=%23holifestival -filter:retweets filter:media&count=20');
How do i fix the duplicate tweets like this? is it possible?
if it's isn't, is there any workaround? please help me.
thanks
You really only have two options.
Compare the text (ignore the URL) and see if it matches a previous tweet. If it does; discard it.
Compare the images. After downloading the image, compare it to other images you've downloaded (either filesize or MD5 hash). If it matches, discard it.
One of Twitter's problems is that multiple spam accounts can be used to repeatedly broadcast identical content. Other than examining the content, there's no way in the API to filter it.

Is there a way to get a list of users based on a hashtag they used?

I want to get a list of users who have used a particular hashtag. Eg. #ManOfSteel.
How can I get a list of the users who are using that hashtag as well as their details (like which city they are tweeting from) using a twitter API or any other means?
Yes, you can. And it's quite simple, really.
According to the documentation:
GET search/tweets: - Returns a collection of relevant Tweets matching a specified query.
Resource URL: https://api.twitter.com/1.1/search/tweets.json
Now if you scroll down on that page, it gives an example of what a query for a tweet returns (I took a screen, sorry about the appalling arrow, it's 10am here and I haven't had my tea yet).
Great! So you know the URL and method (GET) that you need to get your data. As for searching for a hashtag specifically, the query documentation is what you're after.
This is basically as urlencoded string in the GET request like: ?q=#hashtag. Perform the search like that and you'll get back the data above. Then just loop through it, find the user object, and grab the value location key if you want the user's city.
Now, as for a library to interact with the twitter API, you haven't even stated what language you're using. From your profile, you use JAVA I'm guessing. Regardless, checkout the libraries page on the twitter dev site - there's one for JAVA that looks pretty good (and many for other languages too).
If you were using php, this post would be immensely helpful.

How on earth does Google Reader parse RSS?

I'm pulling hair out, i might pull a tooth out next, thats how frustrated i am.
I have deleted (for the purpose of proving a point) ALL my RSS files in my wordpress site
http://baked-beans.tv
No matter what i edit, Google Reader reads what it wants, ie: the posts, and all it's content!
So how on earth am I supposed to edit the content which most of my RSS subscribers will view (since Google Reader is very popular)
If you look here: http://baked-beans.tv/feed/
There is NO content!
And yet if I add this URL to Google reader, it generates full posts in the feed.
Furthermore!
If I edit say... wp-includes/feed-rss2.php I can see those changes within the RSS parser of Safari, Firefox, etc, but again, Google just shows the same thing, the entire post.
This really isnt on. If you go to Google Reader, and click on "Show Details" it says "Feed URL: http://baked-beans.tv/feed/" Which is just a total lie.
I really need to control how people see posts. The posts contain hefty video and a lot of images, and it parses the post in a really unattractive way.
Thanks in advance,
Marc
I'm pretty sure Google is using a cached result because your feed is completely empty (which is invalid RSS, which is probably interpreted as an error condition, like the feed being down).
Try showing a feed that is valid, but empty. That should get Google to pick up the change sooner or later.
If you'd like to edit the contents of posts that were already crawled by Reader, you'll need to republish them with the same GUID (if using RSS) or ID (if using Atom). Reader keeps copies of posts indefinitely (so that it can show historical data for feeds), and it keys things off of the ID. If it sees a post with the same ID as one it already has, it'll update the content of its copy with the new crawled content (more details here).

Resources