API implementation for my social network - php

I know about code development using PHP but not much about modern day web APIs. I want to implement a framework of APIs like Facebbok connect. Myspace connect, Google connect etc for 2 purposes:
1) Users can upload photos to their photo album
2) Other websites can login users using authentication from my site (similar to facebook/Google connect).
So firstly, what is the underline technology / server requirements etc to implement this? Can i use PHP? Then what other schema changes are required? I see facebook has public API keys that other developers use for this. But I am not sure on the implementation.

Probably the best place to start is to read up on http://oauth.net/. I know there are several OAuth implementations in several languages like Java and .NET. I'm confident there is something for PHP (since Facebook is primarily PHP). Just have to hit the google.

I disagree. People use facebook because there is no option out there. I use it too (purely to show off to my friends what a loser I am on weekends when I sit at home and keep posting updates of how awesome my day was). But if i find a better network (not in terms of features but pure trust, a social network that actually respects its users and the information people share, I will switch. Creating an account is no big deal, takes 1 minute. But trust is a life time thing. Once broken it rarely ever comes back. I see it like a relationship. When i created my facebook account 4 yrs ago i was in a relationship with facebook. They betrayed me time after time, year after year and I have no respect for it now. It is like that partner who has cheated on you so many times that today you wish it would just die and fade away. If I find something better and I am out, and all my friends whom I know well enough share my views too. So you will get users, no doubt.
I like your idea of trying to create something, this is how we grow. If everyone thinks like these other people here then there will be no progress in the world. Everyone will be a follower only and not a leader. Google would have said there is a yahoo and microsoft which is huge let's just follow them. But they took their time, fine tuned their model and today they are bigger than these these brands. Of course it is a different story they are a bigger offender of being a big brother than facebook but with power, 99% of the time comes these unethical minds who want to take over the world. If you can fall in the 1% who can have power and remain true to your users, people will follow you in a true sense.

Related

Scalable Webstat Tracking

I am looking for the "best practices" or just recommended methods of tracking stats. If I am developing a site that has youtube-like page stat tracking (views, visits, etc). It is pretty important that I have realtime statistics, but I want to avoid issues when scaling and was wondering if there are other methods to solve this besides caching.
I plan to use Google Analytics for most of the statistics, but Google only updates once every 3-4 hours.
I am a little worried about scalability. Some stats need to be realtime - how does a site like youtube handle it? Do they count stats in memory and then defer a database query to once-every-30-mins or are they just caching read requests and updating those every few hours? What would you recommend doing?
Thanks again SO, I'm so glad that the rest of you can share the wealth of experience that I lack.
I can recommend one method of tracking web statistics, if you have an iPhone, you might want to look at TeddyTrack. (Full disclosure: I worked on the project.) It is as realtime as it gets. In fact if you shake your iPhone, it updates your stats instantly. :-) You only get four graphs but they include (complex) weekly cohort graphs. It's far less complex to setup and manage then Google Analytics. But why choose? Why not get Google Analytics, Piwik, AWStats and TeddyTrack? Use all of them and see which ones you like best. TeddyTrack might suit you because it is very lightweight and it keeps your data on your server. Links:
awstats.sourceforge.net, piwik.org, www.google.com/analytics, teddytrackapp.com.
You can also use no free ones like above mentioned chartbeat.com but they cost serious money.
Not sure which version of Google Analytics you are using but the newer versions support real time stats. Check out http://analytics.blogspot.com/2011/09/whats-happening-on-your-site-right-now.html
Also you could check what sitecatalyst from Omniture (now acquired by Adobe) has to offer. Its been a while since I worked with it, but it is really enterprise and scalable.
All the best!

Is there a open-source forum that I can integrate my current members database with?

So what im trying to do is save myself coding a forum... I've got a members table already with their passwords, username etc etc... and I want a forum system that can possibly be linked with my members table.
So then they don't have to re-signup if they want to use the forum? Ive used PHPBB before but again, that doesn't allow me to link my members table & forum members table.
Site uses PHP/MySQL
Thanks :)
Vanilla Forums pioneered the Proxy Connect method for single sign on -
http://vanillaforums.org/docs/singlesignon
I think an SSO bridge is better than syncing/maintaining two separate user tables (one for the main site and one for the forum). If you can map the existing table to the new one you still might run into encryption problems when it comes to encoding or deciphering user passwords.
I've studied forums with SSO and with a separate log in. The perfectionist in me loves the clean bridge that SSO can provide. However, practically speaking, I've found that a forum's popularity hinges on (1) the number of unique visitors per day; (2) the freshness of the content; and (3) the quality of the content. In other words, SSO is way less of a factor than you might expect.
If you run a popular, high quality site, users will sign up even if it means jumping through an extra hoop to register. I know that seems counter intuitive but that's been my experience. My recommendation is to launch your forum without SSO --- and once you confirm that it will succeed and remain popular, then consider merging the user tables using Proxy Connect.
There is a community contributed code snippet which can be used to authenticate users against an external database: http://www.phpbb.com/community/viewtopic.php?t=1598865 (It is an abandoned thread, so not sure whether it will work)
You can also write own authentication plugins using PHPBB API: http://wiki.phpbb.com/Authentication_plugins
I don't think you'll be able to simply "plug" your current, bespoke user table into some existing forum.
Perhaps I'm misunderstanding the question, but it sounds like you're going to need to write some sort of script that transfers the information out of your database and into a new database in the format that the forum software understands.

Multiple chat rooms, technologies and server load,

I am working on a website where I need multiple chat rooms. Each room will be generated and tied to the content/event just generated by the user and will aproximately last 15 minutes and then autodestroyed. One room will contain aprox. 15 users. Many events will co-exist at the same time.
I have been googling around a lot recently looking for the most appropriate but still easily implementable solution. What I came across are three main paths:
using a mysql-php ready made script (ie. phpfreechat, x7 chat)
using irc channels created on the fly through an ajax or flash web frontend embeded as an iframe (lightirc, qwebirc, mibbit, (advice more if u want))
using some lively generated hosted chatrooms (ie. everywherechat.com, gabbly (i really need to know more of those, again, advice if you can).
Still I have many doubts on all this: irc frontends cant be customized as much as I'd need (ie. disable kick or ban functionalities). Php-mysql solutions, on the other hand, make me think there will be a lot of server load concerns with such a big user-base.
I am on a paid but non dedicated hosting plan. Php memory limit set to 64mb kind of stuff. How many users at the same time would that hold? Hosted solutions are the easiest ones, but can you recommend one that allows rooms to be created on the fly by just passing in some parameters? (no registration, just a quick-easy-flying chatroom).
I know many of these questions are not strictly programming related but more technology related. But still a programming related answer could help me sort out the right direction. So your contribution is really appreciated. Thanks ! Sorry for being long

Logging/tracking in PHP: Scribe, Chukwa, log4php?

This is probably a pretty high-level question that requires a lot of explaining, but I'm in need of a lot of explaining.
Basically I'm developing a PHP application that requires a lot of logging and tracking. Tracking clicks, interactions, performance, etc. etc. Anything under the sun. Facebook's Scribe and Yahoo's Chukwa are both great implementations of this. I know little about log4php.
What I want is a high-level overview of how this kind of logging works, specifically in conjunction with a PHP application. You can stop at the point where the log gets processed; I already know that I want to use Hadoop/Hive for processing and storage.
I'd also like some fairly low-level looks at what happens within the application itself. For example, how does one take the behavior of a click and send that to the logger? I'd appreciate any reading that can help get me started, as well.
You can buy/get the tools to do this for you or build in-house.
buy/get:
1 - Tag your pages with Google/Yahoo analytics - This will track pageviews, page flow performance, SEO ranking for keywords, etc.
2 - For tracking and logging user behavior, which include clicks, interactions and performance. I found nothing better than ClickTale - http://www.clicktale.com/default_e.aspx - It video records user sessions and puts these "log files" in a server.
in-house:
1 - Creating hidden fields in your forms that submits to a logging database also works. You specify unique IDs to forms and keep track of it's actions during submits.
I'm sure there's lots more, but these are the basics. These are not PHP specific though.
HTH
EDIT #1 :
This may be beyond the scope of your question, but tracking doesn't necessarily mean data that goes in-house. An example would be adding a "like it" or "digg it" button to articles or pages. This will "log" popularity for you. You can go to facebook or digg.com to see progress of your site. it'll also help with SEO. basically, it's a tracking system. And it's easy to use. there are PHP snippets out there that you can copy and paste to your code. If you have WordPress, there is a plugin - just look for "digg", "like it" in the plugin search section.
Going back to Google Analytics, if you want to go beyond tracking clicks, go ahead and make goals/funnels. It'll track user behavior, and answer questions such as "What were my most valuable keywords?" "where are all my users dropping off?" "what is the bounce rate for each page?" "what are the top 3 entry points to my site and from what traffic medium?" these are question SEO/SEM managers are most concerned about. and it's definitely good to track and understand.
ClickTale starts where Google Analytics ends. GA will describe user behavior in the page level, but not in the field level. ClickTale, which has heat maps, will answer these questions "I know this page has a high bounce rate, but why? which field is a problem field for my customers?" "At what area of the page do users spend most of their time in?" "how do i prove to the graphics guys that a particular section needs to be redesigned?".
EDIT #2
For high traffic sites, you will need to scale your logging DB. It really helps when it comes to reporting. What I suggest is a 3-tier database reporting structure. tier 1 = last 7 days, tier 2 = last 6 months, tier = everything. You can modify these according to the business. The point being, data moves from one tier to another. keeping fresh data readily available. You want to generate reports asap. A a single huge DB just doesn't scale.
You can monitor user clicks by logging the path the user is taking, referrer --> new uri, assuming both are verbose and descriptive enough. For example, if a user clicks on one of his friends you should log the uris:
Referrer: /users/41251
Target: /users/66257
storing them properly for easy querying and reporting. Here a direct click like that would assume the target is in the referrer's page, so is a friend. If you have more complicated scenarios be sure to describe them with distinct uris, eg: /users/suggestion/14152 for a suggested connection.
Add to that timestamps and you have a very rough estimate of how long they stayed on each page, although users tend to lose focus, switch tabs/applications and come back, etc. Google Analytics, for one, does this well.
For a summary of where users click most on your site using heatmaps I like the free (GPL) Clickheat.
Check out Splunk
On the frontend where you're doing the logging from, here is some sample PHP code that you might find useful:
http://www.alphadevx.com/a/85-Logging-Messages-to-Scribe-from-PHP
In terms of the architecture, you have a lot of flexibility with Scribe. I would recommend having a local Scribe instance running on each application node, and having your application log locally to localhost. These local Scribe instances can in turn be configured to log to a central Scribe server when it is not too busy, otherwise they will continue to queue up messages locally. You actually consume your logs on the central server where they are aggregated by category.
I'm a big fan of Scribe, and I think it's designed well is so far as it's got a very small memory and processor footprint, and it is quite easy to configure (although murder to install due to the dependencies!). It just lacks documentation.

Thumbs system on Urban Dictionary

I was thinking of implementing a thumbs system, but mine would require a registration thus ruling out the possibility of people voting more than once unless they create a new account to do so. So I was wondering about Urban Dictionary's thumb system. How does it work? I would imagine that my IP would be stored in a database, so people would not be able to vote more than once however IPs do change pretty often and especially when you're on an iPhone. Probably a combination of cookies and IP checking. Can anyone give me a better insight? What would they check for to ensure you don't vote more than once?
The reason I ask is because I may want to make my a public system instead. Maybe even a hybrid, similar to SO where you can ask a question before creating an account and then have the two linked together. I am using PHP and MySQL.
Almost always it's done with cookies. As you say, IPs can't be used (naively) as they change, or cover too many people (i.e. everyone in a given office, etc).
But online polls not reliable anyway, so don't get too concerned about solving a problem no-one cares about. You can implement more 'intelligent' rules but then you need to ask what benefit you are getting for all your work.
Personally, I would go with:
Cookies
Forced signup voting
Some sort of analysis of voting patterns
Because it goes without saying that people can just sign up constantly, to submit more votes. It really depends on what benefit people get from voting, and how much you care (in terms of time, which is, obviously, money).
I know urban dictionary allows for more than one vote per day. Once every six hours to be exact.

Categories