Can I have my app scan my Twitter stream for news to show the user? - regex

I would like to be able to show short news messages to users of my app. I am thinking the nicest way to do this would be to add a hashtag (like #appnews) to my Twitter updates that I want shown in-app; my app will make this happen by scanning my Twitter stream at startup and surfacing updates with that hashtag. This seems super-simple, and I'd like to know if there's some way to do this via built-in (HTTP?) calls to my Twitter page, rather than incorporating a whole framework like MGTwitterEngine. The user will not be logging in or posting Twitter updates at any point.
Thanks!

You can retrieve any user's public tweets in XML format by retrieving the following URL:
http://api.twitter.com/1/statuses/user_timeline.xml?screen_name=DWRoelands
(This example will display my tweets). Once you've got the list of tweets, you can parse through the XML document in whatever way is easiest for you.
Rather than tagging posts with a hash tag, I would recommend simply starting a new Twitter account that is solely for the news items you described.

Related

Facebook OpenGraph: Getting like count of post without User Token

I have an existing app that uses the Facebook API & login that makes posts to the user's wall. For each post I store the id of that post.
What I need to accomplish is to gather like counts of those posts generated by the first app. I'm trying to write a small app that routinely pulls the like count. I've figured out how to get the like count of the post if I use a User Token - via Facebook Login. But since this app will run as a batch and not by a human, I don't want to use a Facebook login page. I could write code that simulates a user logging in but that would be a major ugly hack. I've tried to use an App Token but then the like count is always zero. I've found how to get the like count of a page without the need for a User Token http://www.techrecite.com/get-facebook-likes-count-of-a-page-using-graph-api/ but not a post
Is this even possible? If so how?
I've looked into Facebook API's subscription, but it doesn't seem possible to subscribe to a "like-a-post" event. Although I could be wrong. If so, could someone point me in the correct direction.
Thanks.

Facebook opengraph insights api on specific post id from my app

I want to build a dashboard that returns more customized insights from the insights generated by app.
The app is a facebook connect website that users visit and view a list of products. They can post to facebook about that particular product by sharing a custom story that incorporates that product on their timeline.
When I go to the insights for my app, it does a great job of showing me all social impressions for all custom stories that were generated on my site.
I'd like to narrow that down even more for specific products.
My plan is to record the object ids that are generated by these actions and link them to a partucular product in my database.
I'd then like to create a new dashboard page that will allow me to login, request read_insights permission from me and then use that object_id:product mapping from my database to show how many social impressions where recorded for a given product's object_ids.
Is this possible? I've read alot about it but still haven't found the most elegant way to get a segmented report of social impressions per type of content that was posted.
Thanks for your time.
The implementation all depends on which platform you want your app to run on.
The first major component is you must have a Facebook developers account which is easy to signup for. Just go to developers.facebook.com and register. Takes like 2 mins. After that you will need to create your first app and add the correct domain name where your app will be hosted and what platform it will run on. (iOS, Android, Web, ect.) Once that is finished you can make your app public so you can use the Facebook API in your code.
For the app creation itself. The first thing you need to do is import the correct API for your platform. Which you can find a walk through at https://developers.facebook.com/docs/. Once the API is imported you must build a Facebook object which contains your app id and possibly app secret. If you're using JavaScript you don't want to use the app secret because it will be visible to the public.
Now that you have your Facebook object you must require the app users to log in and grant permission to your app. You can add extended permissions to your log in process by adding a scope value to the log in button generated by Facebook. Here is an example.
<fb:login-button id="loginBtn" max_rows="1" scope="basic_info,read_insights,manage_pages" size="medium" show_faces="false" auto_logout_link="true"></fb:login-button>
After the user is logged in you can now query information from the users account using Facebook Api calls to Social Graph. Facebook also provides a tool to help you figure out what information you can query. https://developers.facebook.com/tools/explorer
Everything else you want to do with the app can be done by Facebook API calls. You just need to insure you grant the user the correct permissions before making the API calls.
API calls are a little different depending on which language syntax you are using but they all follow the same data model and return some array of responses which can be parsed using JSON or the standard array format. The Graph Explorer tool listed above will show you the output for your queries so you can handle them accordingly.
I hope this helps gets you started.
EDITED
Here's the implementation in JavaScript
function getMetric(){
// make the API call
FB.api(
"/{app-id}/insights/application_opengraph_story_impressions",
function (response) {
if (response && !response.error) {
/* handle the result */
}
}
);
}
Here's the reference now that Facebook docs are back up https://developers.facebook.com/docs/graph-api/reference/insights
application_opengraph_story_impressions will probably give you the total impression of all stories made by your app. I ran it against my Facebook app and it came back empty but I don't have any stories so it might work with your's. Also to note in the documentation there is an * by this metric and I could't find what that means.
I'm pretty sure that right now Facebook don't give developers ability to get insights about app custom stories.
Currently Facebook documentation has the following Graph APIs for Insights data:
/{page-id}/insights
/{app-id}/insights
/{domain-id}/insights
/{post-id}/insights (where this is a Page post)
So /{post-id}/insights won't work because custom story is actually user's post and others endpoints don't apply to your case.
As far as I know the only other option to access Insights is FQL. For that you'd use insights table in a manner similar to this:
SELECT ... FROM insights WHERE object_id = ... AND metric = ... AND end_time = ... AND period = ...
Now most likely this also won't work with your custom story posts (I don't have posts which I could try it on right now, so I can't tell) but at least it is not explicitly stated so in the documentation, so you should probably try it out.
UPDATE:
I wasn't able to get any insights data via FQL, although as far as I understand the following code should have gave me at least something (object id is for my page):
SELECT breakdown, end_time, event, metric, object_id, period, value FROM insights WHERE object_id = 224981264214413 and metric = 'page_fans' and period = period('lifetime') and end_time = 1395597892
But it results just in
{
"data": []
}
Facebook also has some pretty old bug report about similar topic: https://developers.facebook.com/x/bugs/508088155954330/ where they confirmed the issue, assigned it, and... did nothing to fix it for 6 months.
In case FQL doesn't work, my suggestion to you is - use your own analytics code to track the creation of custom stories and get the friend count of the users. It won't show you the real exposure of the posts but at least you will see some data on which types of custom stories where posted more often and what was the maximum potential friend count that could have seen them. By the way - to make charting easier, you could use Google Analytics events for that.

How to get multiple user images from Twitter (OAuth)?

I have a log in to my site using Twitter. It all works great.
Whilst I can do a call to get the current users details etc and log them in, I'm a bit stumped on how I make calls to get the profile images of users stored in my database; those who may not be using the website at that time?
I am using the monkehTweets Twitter library:
https://github.com/coldfumonkeh/monkehTweets
To get the current user, I sign them in and do this:
application.objMonkehTweet.setFinalAccessDetails(
oauthToken = returnData.token,
oauthTokenSecret = returnData.token_secret,
userAccountName = returnData.screen_name
);
local.userDetails = application.objMonkehTweet.getUserDetails(user_id=returnData.user_id);
As part of the log in process on my website, if a user hasn't used the site before, I store their Twitter ID.
I was hoping to then use this to display their profile images on the posts they make to other users.
What is the best approach to achieve this? With the Facebook API, you can make requests to a URL with the ID...but Twitter doesn't seem to allow this.
I would prefer not to 'store' the image on my own file system. This was a possibility I had in mind, but I'd rather use the API to always ensure the latest data.
Is there a way to use my own app details through OAuth to access this?
Any help would be greatly appreciated.
Thanks,
Michael.
PS - I am using ColdFusion (Railo) to do my server-side based authentication.
The twitter api returns profiles with the images (if you are looking it up) in the key profile_image_url
So you could store them in a cache like:
if(!cacheKeyExists(twitterID)){
// Code to get a twitter profile through monkehtweet
cachePut(twitterID, profile.profile_image_url);
}
return cacheGet(twitterID);
Hope this helps

HTML5 Canvas to Facebook

I've made a basic HTML5/JS comic creation tool that uses the canvas element.
I want users to be able to upload their comics via the Facebook API.
I don't believe Facebook allows posting images in the form of base64 strings from the canvas.toDataURI() method, and don't want to use my own server to convert these images & temporarily store them.
What's the best way to go about this? Possibilities I've wondered about: Convert canvas to blob? Store blob via web service (if so, suggestions?) Upload blob directly to Facebook? (Is that possible?)
I don’t see why this should not be possible doing a „normal” upload. You can create a new photo for a user by posting to PROFILE_ID/photos, with a source parameter of type multipart/form-data.
So first thing I’d try is getting the picture info from the canvas object into a „normal” form (writing it into a input element in the right format(?)), and sending that to Facebook. If this step succeeds, I’d see if jQuery or some other lib’s form.serialize method can build requests of type multipart/form-data. If that’s also possible, then there should be no further problem in taking the data in that format and posting it using FB.api (although you might want to tell your users to be patient, because that might take a while).
Can’t tell for sure if this’ll work, but I’d give it a try.
Facebook partners with Heroku for free app hosting, you can use it as the temporary server.

Facebook like notification updates using django signal or notification

How can i use django-notifications or django-signals to make something like facebook updates notification that shows in the user profile if any other user likes or posts comments on user's blog or posts?
For the activity feed, we use https://github.com/justquick/django-activity-stream Documentation: http://justquick.github.com/django-activity-stream/
For the js widget and live notifications, we use https://github.com/subsume/django-subscription yourlabs example, it depends on redis but you can easily add a model backend if you really want to. Redis is a good choices it's half a megabyte of dependency. Documentation: http://django-social.rtfd.org
There is no application that does meta-notifications ("notification groupping") properly but a lot of research has been done. Basically you need another app, with a MetaNotification model, and something (management command, signal ...) that will visit notifications and create MetaNotification instances. Then you should display MetaNotification lists rather than Activity or notification list.
Finnaly, if you want configurable email notifications then you can use django-notifications: https://github.com/jtauber/django-notification or this app which looks nicer: http://www.tomaz.me/django-notifications/
I'm not aware of any app that does it all. It is going to be some work for you.
"It's a long way to the top if you wanna rock'n'roll" or as I like to say "patience and perseverance" :)
https://pypi.python.org/pypi/feedly allows you to build newsfeed and notification systems using Cassandra and/or Redis. Examples of what you can build are applications like the Facebook newsfeed, your Twitter stream or your Pinterest following page.