Twitter API grabbing/caching/parsing multiple streams - php

I need some thoughts in this :) I think i might be trying to do the impossible.
I’ve got a website with a lot of company profiles (300+).
I want to place a stream on every profile page, and allow the owner of that profile page to enter some keywords in the backend with the keywords they want the stream to display.
1 thing would be to do this with javascript on the fly, on every profile page.
But, since I want to use the combination of every profile stream on the frontpage and parse images in a tweet (yfrog, plixi) i thought it would be best to cache them into a mysql db, and work from there with PHP. (Maybe SEO advantage over Javascript? )
Is this even possible ?
My first bet was to make a REST call to the api with the keywords from all company profiles ,put them to the DB and store which keyword would be connected to that tweet.
Any thoughts on this ?

You could use the Streaming API with a track filter, that would allow you to capture all statuses matching the keywords your profile owners select. By default, you're limited to 400 keywords, but could ask Twitter to increase you're access level (they list a few levels in the documentation).

Related

Most efficient way to load all facebook friends with API and Laravel for further processing

I'm building an application which should display all of the users Facebook friends. The entire list should be searchable (name) and filterable based on gender and in the future other parameters such as location.
So Imagine you go the the web page, you get your first 30 friends loaded (or whatever fits on your screen) and as you scroll, more friends will load. As soon as you type, the system will begin to search for names.
Now i'm wondering what an efficient way of doing this would be. Obviously I can't load all the friends on the page because some people have over 1000 friends and the page also displays their profile picture.
Because I need to do the filtering I'm not quite sure if I should load the entire friends object in one go and do the processing with PHP afterwards, or if I should load it asynchronously from facebook as the user scrolls down.
My ideas is to load the entire friends list, flash it in the session and grab it again when processing is required such as filtering and searching.
Would that be the way to go?
Friends don´t change very fast, so you can just grab all of them at once with limit set to 5000 (maximum of friends) and use them in the whole session. I just hope the API allows the limit to be set that high.
me/friends?fields=id,name&limit=5000
It is the only way you can use the search, and only one API call is needed. After all you only get the Names, and add Avatars as soon as they are visible in your app (Right after searching, for example).

Linking to specific tracks through the iTunes affiliate program

My iPhone app links to songs on the iTunes store, through the linkshare affiliate program, up until this point I had been creating the links manually - which albeit is time consuming but I had no problem previously. The application has new songs every day and manually creating the links is getting out of hand. However, having read through all the affiliate program documentation I cannot find a way of linking to a specific track on the store - without using the link builder. The only data on the song I have is the track name, artist name and album name.
Obviously I can use the search api, but that does not seem to enable the affiliate linking - so I cannot benefit from the sales.
http://itunes.apple.com/search?term='.$tracksearch.'&country=gb&media=music&entity=musicTrack&attribute=musicTrackTerm&limit=1
So my question is how would I go about linking to a specific track, through the linkshare affiliate program according to the three pieces of data I have?
(I am using PHP for any basic data interactions - just in case anyone offers any coded methods - bearing in mind i'd like to produce the link on the server so my app can simply fetch the data from there.)
Obviously I can use the search api, but that does not seem to enable the affiliate linking - so I cannot benefit from the sales.
The Search API is exactly the tool you want to use. The API will return you the link you need, it is up to you to affiliate encode the link after you have that information.
The encoding process can be found in the documentation here:
http://www.apple.com/itunes/affiliates/resources/documentation/linking-to-the-itunes-music-store.html

Multilingual fan pages

I've got an algorism that is calling the Graph API to grab the posts of fan pages that we don’t have in our database (to make statistics on them).
We call the Graph API with an app token, and with “normal” fan pages (no located posts), we don’t have any problems, we correctly have all posts.
But when we try to grab country located posts, the Graph API returns to us nothing. I think it’s due to the fact that an application don’t have a language (by default), so to resolve that, I take the access token of an admin of the page and then the Graph API give me all the data I need.
My question is simple : Is there a way to grab country located data with app token ?
Thank you for your answers !
Unless you own that page, no, there is no way. This would create a privacy issue where the Graph API can be used to display otherwise restricted content. This applies to age and alcohol restrictions as well.

Facebook API. Remove tags, wallposts, messages from a certain user

I'd like to remove as much as possible of my history with a certain facebook user via the Facebook API.
I want to be able to remove photo tags, wallposts, messages that I am tagged in, or associated with the certain user.
Is this possible, and if yes; how?
Blocking the user will go a long way towards removing most connections with the person in quesion. Go to Account->Privacy Settings->Manage Block Lists, or go to the users profile and look for the "Report/Block" link under their friends/family lists.
This FAQ about blocking describes a little about what happens when you block someone. As far as photos goes, it's a little unclear:
Photos: If the blocked person tagged you in any photos before the block, you’ll still be able to see those photos. You might also see photos of the blocked person if they are tagged in another friend’s album, but you won’t be able to click on their name to see their profile.
You do automatically get un-tagged from all their photos when you block someone. I'm guessing wall posts you're tagged in are removed as well, although I only tested with photo tags.
As far as removing their posts to your wall, as Igy pointed out you can't write an app that uses the API to delete posts that it didn't create. So, what I would do is write an app that gets all the posts on your wall and filters them, something like this pseudo-code:
posts = api('/me/feed')
for each post in posts:
if post.from.id == [blocked persons id]:
output post.id
Post ID's from the Graph API are in the format USERID_POSTID, so there are two ID's separated by an underscore. So for each ID in the output, go to https://www.facebook.com/permalink.php?story_fbid=[POSTID]&id=[USERID] and manually delete the post by selecting "Remove post" from the little gear menu on the top right of the post. Use the paging data from your API request, or until and since parameters (which are just UNIX timestamps, or any string accepted by the strtotime function), as described on http://developers.facebook.com/docs/reference/api/ under "Paging", to get all posts going back until the beginning of your wall.
If you are wanting to automate this process to make it available to end users and not just yourself, there are technically several ways you could go about it, although they may or may not violate (Terms of use)[http://www.facebook.com/terms.php]:
[3.2] You will not collect users' content or information, or otherwise access Facebook, using automated means (such as harvesting bots, robots, spiders, or scrapers) without our permission.
I'm sure there are ways of implementing such an app that doesn't violate these terms, for example providing a link to the post so that they can delete it themselves, rather than automatically deleting them.
http://suicidemachine.org/
I'd look into their code.
From their FAQ on if you can make your own:
Theoretically yes! Practically no (or let's say, not yet)! You'd need a Linux WebServer (apache2) with perl and python modules (php should be installed as well). Further, you'll need VNC-server and Java packages by Sun to launch selenium-remote applets. If you feel like contributing and can convince us with decent programming skills, please get in contact with us via email. We don't make the source code publicly available, since Facebook, Twitter, Myspace and LinkedIn would figure out how the suicidemachine is working in detail! So, please do not contact us, if you work for one of these companies!
I'm not even sure (personally) why you'd want to do this, surely you'd either want to block the other user or just remove them as a friend, but to answer your question:
It's not possible to delete most types of content via the API unless the App ID you're using was the original creator of that content (e.g an app for posting to your wall can delete the posts it made, but not posts made by other apps or on the Facebook.com interface)
Check the documentation at http://developers.facebook.com/docs/reference/api/ - you can definitely remove likes and comments of photos and wall posts - there may be other ways to do this (e.g retroactively changing your RSVP status to an event both users went to)

Facebook keeps deleting my application

FB keeps deleting my application. I am thinking that the likely problem is that we allow users to share their score result with their friends, i.e. the user can select group of people who are also in the same group, and the script will post on all of their walls. I don't think that app is acting in any way not in accordance with FB policy. My guess instead is that due to relatively high amounts of requests to post feed [some users can select 100 and more friends]. Can it be so? Is there a way to post multiple feeds in single request, in that case?
http://developers.facebook.com/docs/guides/policy/policy_checklist/
Ensure that the application "does not provide users with the option to publish more than one Stream story at a time."
The behavior that Facebook wants you to use is that a user posts something on his own profile to share it with multiple people. Posting the same story on multiple profiles at once is contrary to how the social channels are meant to be used.

Categories