Posts Tagged Facebook

How to get your Facebook follower count in PHP

If you’re looking for a way to fetch and display your Facebook follower count in PHP, here is your code. In the below, substitute __ID__ for your numeric ID for your app or page, and __TOKEN__ for your access token.

Please consult the Facebook Graph API documentation for more information.

This method uses file_get_contents() rather than the preferrable cURL() call. Also, don’t forget to cache your queries, or you may experience API throttling. See the Rest & Graph API Best Practices for reference on this.

Here is the code:

function GetFacebookFollowerCount(){
  $json = file_get_contents('https://graph.facebook.com/__ID__/insights/page_fans/lifetime?access_token=__TOKEN__');
  $obj = json_decode($json);
  $new_facebook_followers= $obj->data[0]->values[0]->value;
  return $new_facebook_followers;
}

Comments and feedback are welcome.

, ,

Leave a comment

Ten ways to advertise your website or blog that don’t cost money

Webmasters and bloggers are always looking for ways to advertise their sites and increase traffic. There are a lot of ways to do this that don’t cost a penny.
Here’s some of my suggestions in no particular order…

Produce good-quality content and have it indexed by the search engines

People want content, and content sells itself. If you’re searching for something, then come up with what you’re looking for, why not mention it with a link? Or, if you solve a problem with a piece of software, or find a bug, write about it. Certainly other people have run into the same thing, and they’re likely looking for the same thing you were. Help them find you.

This is actually a lot easier than most people realize — it only takes a few steps to set up, and the rest of the crawling is done by the search engines automatically. Don’t bother with sites that want you to pay to submit — you can do it yourself in a few minutes, and it doesn’t cost anything. Depending on your CMS software, you can likely find a plugin to help with generating and submitting your sitemap. Read more about it here.

Participate in forums and have your URL in your signature

An easy method if you’re already involved in one or more forums regularly. Simply edit your forum signature to include your site’s title and a URL. You can also do this with your email signature to hit the people you email as well.

Leave comments on other blogs and link back to your site

This is great when you can find a blog that’s related to yours, or has a post about a topic that’s related to something you’ve already written about. Simply post your thoughts on the issue, with a segue “I mentioned this at…” with a link. I have gotten a lot of traffic this way, though it relies heaving on the other blog having traffic, and catching people with your brief statement enough to make them want to click through. It can be done, and it works very well.

Link to other blogs from your own posts to generate “pingbacks.”

I’ve seen this done well, and I’ve seen it become spammy at the same time. When you link to another blog from one of your posts, (depending on the platform) the software will generate what’s called a “pingback“. This means it posts a link to your site at the site you linked to. It can be good to generate links to your site.

Post links to your new articles on social networking sites like Facebook, Twitter, MySpace, etc.

Again, can be very effective, can also be very spammy if not done correctly. You’ve written a great interesting article that you want people to read. Post a link on your favorite social-networking site — Facebook, MySpace, and Twitter to name a few — and people are sure to click on it, right? Just make sure they’ll find the story as interesting as you did, and avoid over-posting, or you’ll lose followers faster than you can create new posts.

Submit your RSS feed to aggregation sites like Facebook, Digg, etc.

Facebook has a feature in Facebook Notes that allows you to submit an RSS feed that will publish your posts as Notes. The new Digg also has a feature that will allow you to submit an RSS feed to be automatically published on the site. Many other sites also support this, and it’s a great way to have your new articles automatically pushed out there. There is a downside to this: People will read the article on the published site and may not click through to your site. Try including links to other posts inside your own to get those click throughs.

Personally email out links to articles that others would find interesting.

Email marketing is great, and has a very high click-to-impression ratio. This means that, for every person that looks at your link, a lot of them will click on it to read it. Now, be careful with this one, and try not to get spammy. Opt-in mailing lists are great if you can get people to sign up, and you will have a very low likelihood of upsetting someone that doesn’t want to get your emails (or worse — having them report you as a spammer), but if you know you have an audience, shoot them an email, but make sure it’s personal.

Consider Creative Commons

Creative Commons is a set of copyright rules that, among other rights, can allow others to publish your content providing they provide credit in a manner of your choosing. This can include a link back to your site. Interested readers finding these articles can see your authorship on them and click through to your site to see whatever else they might be interested in.

Participate in Link Exchanges and Blogrolls

If you know someone who has a website or a blog, ask nicely if they’ll post a link to your site on theirs in exchange for the same on yours. A well-placed link on another site can generate traffic from an interested visitor, and the other site will no doubt appreciate the same from you.

 

,

Leave a comment

Captchas, Anti-spam services, and Bad Behavior

I run this WordPress blog as well as a Drupal-powered forum site and one of the biggest challenges that any webmaster can have is controlling spam — both in comments and user sign-ups.

I used to rely heavily on captchas, and I’ve gone through several captcha and non-captcha systems to try to find the “ideal” solution: One that cut the spam down to nearly nothing as well as not putting too much of a burden on the legitimate users (as to possibly deter them from participating on the site).

Here’s what I’ve tried, and what I’ve learned in the process:

reCAPTCHA (WordPress, Drupal): This service aims to stop bots and spammers by presenting two words.

Pros: As a side effort, the service also aims to help digitize books by using the legitimate users to correctly identify one of the mangled words provided. Also has a feature called “reCAPTCHA Mail Hide” to hide email addresses behind a captcha to keep them from being harvested by web bots.

Cons: reCAPTCHA has one distinct weakness: Only ONE word needs to be correctly entered to pass the captcha. Additionally, at least one implementation has a weakness making the captcha worthless.

Mollom (WordPress, Drupal, Joomla) : Mollom is a text analysis service with a captcha fallback.

Pros: Aims to be unobtrusive. Does not present the user a captcha unless textual analysis cannot be performed or appears to the service to be a spam submission. Captchas are “cleaner” looking than other services (less visual distortion). Audio captchas.

Cons: Limitations on the free service, and does not scale well. Free service only allows 1,000 legitimate posts per day, then it’s 30 EUR/mo/site. (Around $50 USD). No service uptime guarantee with the free service.

Akismet (WordPress, Drupal) : Akismet is a non-captcha anti-spam service that does textual analysis (similar to Mollom) except completely without the aid of captchas.

Pros: Comes installed on all WordPress.COM blogs by default and needs no configuration. Powered by, and maintained by Automattic, the same team behind WordPress and Gravatar. Suspicious submissions are placed in a moderation queue for the administrator to manually approve, with the option to automatically expire (delete) them after 30 days or so. Easy setup via an API key.

Cons: Akismet weighs input the same across all Akismet-protected sites. This means that someone who submits a comment on an Akismet-protected blog that gets flagged as spam would get the same treatment on an Akismet-protected forum (and every other Akismet-protected site for that matter) until enough comments get marked as false positive for the system to re-learn the user is not a spammer. I had a user that got hit by this false-positive treatment the first day I implemented Akismet on another site and it became a hassle. When I enabled Akismet on this WordPress site, his comments were still getting flagged as spam. That’s a serious issue for me. (Akismet FAQ)

Defensio (WordPress, Drupal, Facebook) : Similiar to Akismet, weighs each source seperately, and offers Facebook protection as well.

Pros: Defensio is a service similar to Akismet, but weighs content from each website (blog, forum, etc) separately to avoid mistakes. You register each web property you want protected and obtain an API key for each. Slow to learn at first, but avoids false-positive/negative and cross-property disasters like I mentioned above with Akismet. This service is a favorite of mine. Additionally offers profanity / file link protections, as well as customizable filters. (Link)

Cons: Slow to learn at first. Might require you to manually flag content until it learns. Currently free, though they mention possibly charging for the service in the future for commercial users.

Bad Behavior (WordPress, Drupal, Joomla) : Not a captcha or textual analysis service at all, takes a completely different approach

Pros: Filters access at the http level, by blocking proxies, historically abusive IP addresses, suspicious user-agents, and malformed requests. Cuts down on bandwidth, spammers, users who are accessing site content through known proxies, etc. Conserves server bandwidth and resources, as pages are not served up at all when a block is performed. No training required.

Cons: It’s possible that a number of users whose ISPs force proxies may be blocked, but I have not seen evidence that this is happening on my sites.

So there you have it. Personally, I use a combination of Bad Behavior and Defensio on my sites, and I’ve seen a big drop in the amount of spam.

Have experience with one or more of the above? Please share it!

, , , , ,

Leave a comment

Ubuntu Karmic post-install Guide

Ubuntu Post-Installation Guide v9.10

Note: Unless otherwise specified, packages are installed/uninstalled using
System > Administration > Synaptic Package Manager.
Repositories are updated in
(System > Administration > Synaptic Package Manager > Settings > Repositories)
or
(System > Administration > Software Sources)

> Third Party Software (for Jaunty) or
> Other Software (karmic).

Java, Flash Player

By default, openjdk-6-jre is the Java VM used on Ubuntu. This is because OpenJRE is actively developed, while Sun’s Java VM is not. Also, by default, Flash is not installed. To install Sun’s Java VM (which can be successfully installed alongside OpenJRE) as well as Flash Player, install: ubuntu-restricted-extras

Medibuntu (DVD, MP3 and WMA support, etc)

Additional codec support (MP3, WMA, etc) is provided by the non-free-codec in the Medibuntu repository. (See for information) Running the following lines in a terminal will install the correct Medibuntu repository as well as the required keyring to authenticate packages:

sudo wget  -cs).list
--output-document=/etc/apt/sources.list.d/medibuntu.list &&
sudo apt-get -q update &&
sudo apt-get --yes -q --allow-unauthenticated install medibuntu-keyring &&
sudo apt-get -q update

(Reference https://help.ubuntu.com/community/Medibuntu)

Following that, install the following packages:
libdvdcss2 (Allows to read encrypted DVDs)
non-free-codecs (Additional codecs)

Compiz

On supported video chipsets and with the correct video drivers, Compiz can enable a variety of visual effects. If Compiz is supported on your system, it can be enabled via System > Preferences > Appearances > Visual Effects and settings the level to Normal or higher. If compiz is enabled, it is recommended to install compizconfig-settings-manager

Other Useful Programs

The following packages are useful, and installation is encouraged:

APPLICATIONS MENU
–sound and video:
amarok
(music management application which also supports a wide range of MP3 players)

–internet:
While empathy is the new default IM client, pidgin is recommended for facebook users. Empathy, at the present time, does not have the same level of facebook
support that pidgin has). install:
pidgin and pidgin-facebookchat

–system tools:
gnome-format (a tool to easily format removable memory cards)

–other
fglrx-amdcccle – Catalyst Control Center for ATI graphics cards
nvidia-settings – Tool for configuring the NVIDIA graphics driver
nautilus-wallpaper – Adds ‘Set as wallpaper’ to right-click menu
nautilus-image-converter – Adds ‘Rotate’ and ‘Scale’ image commands
to right-click menu

VirtualBox

A free Virtual Machine system.

virtualbox-ose is available directly from Synaptic, but does not support USB device pass-through (allows the VM to communicate with USB devices). Sun’s VirtualBox 3.0 does support USB device pass-through easily.

See http://www.virtualbox.org/wiki/Linux_Downloads for instructions on how to add the VirtualBox repository to your system. After adding that repository, you can install the virtualbox-3.0 package.

Be sure to give yourself access to VirtualBox using System > Administration > Users and Groups
and give yourself User Privileges to ‘Use VirtualBox’

Intel microcode update

Systems with Intel CPUs should install the intel-microcode package. This provides an updated microcode to the processor at boot-time which can address processor errors and lock-ups.

Broadcom wireless issues

Systems with broadcom wireless cards which are detected but do not show any wireless networks should install the b43-fwcutter package. This provides an updated firmware for the card which fixes numerous issues. This would have to be installed using a wired network.

Dropbox on Ubuntu

Add the repository line for your Ubuntu distribution and install the nautilus-dropbox package (Reference: http://www.getdropbox.com/downloading)

Other Software

It is strongly recommended to use software that is distributed in the repositories. If you need to install a program from another source, the .DEB format is the best choice. This installs the program and adds a listing in Synaptic for easily unisntalling the program when you want to.

, , , , , , , , , , , ,

Leave a comment