facebook_logo

As you all know recent changes in privacy issues made Facebook to change their basic API and added some security concerns. From my best practise, most of the old applications are safe, but you will be in trouble when you create new application. By default you cannot access user’s photos, profile pictures , albums etc. If you continue with old REST API, you may face this problem. You will get an empty array or json string when you call photos.getAlbums function.

If you test these functions from Facebook Console Tool:

http://developers.facebook.com/docs/reference/rest/photos.getAlbums

It returns real value when you select old applications and returns empty string [] if you select your newly created Facebook app.

To get all those support, you need to use new Graph API

But if you follow the same steps mentioned in that official document, you will still get this empty string problem. Because, in the basic authentication call, there is no permission type is mentioned. You can only see a basic message with Allow or Deny button.

According to that document, as the part of authentication, you need to call this url with your client id and redirect url and it returns an access_token after a #

https://graph.facebook.com/oauth/authorize?
    client_id=...&
    redirect_uri=http://www.example.com/oauth_redirect

You need to use this access_token to request all other functions, eg:

https://graph.facebook.com/me?access_token=...

This call will work for most of the requests except photos or albums. So the mistake in these calls are the permission.

Here is the correction:

https://graph.facebook.com/oauth/authorize?
    client_id=...&
    redirect_uri=http://www.example.com/oauth_redirect&perms=publish_stream,user_photos

Here we pass perms parameter to set different permission and if you use the access_token after this request , you can access user photos and albums. You can see another permission popup with album and photo access.

Here is the list of such extended permissions in Facebook.

This is the problem when you use new Javascript SDK for graph API, or when you try to integrate these API in PHP or PERL or any other Server side scripting language from the scratch.

If you use new Facebook PHP Graph SDK , you cannot get these problems, but there is still another hidden problem if you continue testing code by the example provided by them.

It is my next POST . See you at there

Thanks

Sajith

Tags: , , , , , , , , , , , , , , , , , , , ,

· · · ◊ ◊ ◊ · · ·

php

Like the old REST API, you don’t need to add 2-3 files for Facebook PHP SDK. The new graph api comes in a single file which is located at http://github.com/facebook/php-sdk/

Copy the facebook.php file in to your webroot and include this file in your php code.

require_once(‘facebook.php’);

To work fully functional, you need CURL and JSON installed in your server. To check this use phpinfo() function.

To make sure, these missing is the main problem, add  exit(‘Curl error’); just above the line   throw new Exception(‘Facebook needs the CURL PHP extension.’); in facebook.php file.

Same for JSON.

The Linux way of installing CURL is :

sudo apt-get install curl libcurl3 libcurl3-dev php5-curl

To install JSON in your linux machine, follow these steps:

  1. pecl install json
  2. Add json.ini file in /etc/php.d/
  3. edit json.ini (in VI) and add this line: xtension=json.so
  4. Save the file and restart appache (/etc/init.d/httpd restart)  or apache2 restart depends on your linux OS

See the example.php file in php-sdk from Github, if you call getSession function, you only get a NULL string if you are not logged in proper way. So I recommend to redirect into login page if there is no session available.

Here is the change:

if (! $facebook->getSession()) {

header(‘Location: ‘.$facebook->getLoginUrl());

}

Then try the rest of the part as per example.php , it will work

Good Luck

Sajith

Tags: , , , , , , , , , , , , , , ,

· · · ◊ ◊ ◊ · · ·

There is a very strange issue with PHP session when you prefer session to save in files other than database (normal session).

The problem is: some times you can access all the saved session values from $_SESSION and sometimes it returns a empty array.

If you refresh 10 times, perhaps 4 times you will get session and 6 times you will get it empty.

The problem is not due to domain level security or session expiry . It is due to session file location. If you run a phpinfo() function in any of your page, you can see there is a part of sessions. There you can see a session variable session_save_path and it will be pointing to /tmp/ or /etc/somefolder or /var some folder inside the linux file architecture.

Since at clouds, different servers server at different time, some server can see the exact saved files in that location and some server cannot. (Since /tmp etc directories are not shared among them)

Solution:  Call the below php function and set session file path inside your web root . You need to call this function before your session_start() call

eg:

session_save_path(‘/mnt/stor1-wc2-dfw1/4675/5044/to/your/website/rootfolder/or/inner/directory);

For windows users as well, this is the solution. This problem occurs in ASP application as well.

Thanks

Sajith

Tags: , , , , , , , , , , , ,

· · · ◊ ◊ ◊ · · ·

JBar – Jquery Bar

27 Dec 2009

Flash messages or notification messages are very essential part of every update/edit or delete operations. We either use ajax update messages like “You account has been updated” or “Your photo has been successfully deleted”

Here, a new plugin of jQuery can be used to display the flash messages like twitter. (see twitter’s settings page)

I added some more functions to this plugin to display the notification in different context, say information, warning or error message. The function show_flash(‘message here’); can be used for this purpose. Second parameter is the type of message. For example, show_flash(‘Error in deleting file’, ‘error’) OR  show_flash(‘Email address entered is invalid’, ‘warning’)

If you use sessions to save flash message , for example in codeigniter $this->session->set_flashdata(‘message’,'hello’); you can use this plugin to display them by adding a php code in the footer  (or header) of every page

<?php if($this->session->flashdata(‘message’) != ” )  : ?>

<script>show_flash(‘<?= $this->session->flashdata(‘message’) ?>’)</script>

<?php endif; ?>

Here you can download the full source code:  http://www.sajithmr.me/downloads/jbar.zip

Screen shot 2009-12-27 at 11.30.12

Thanks

Sajith

Tags: , , , , , , , , , , , , ,

· · · ◊ ◊ ◊ · · ·

If you are facing onchange and form submit of select-box (combo box) in html, you are not alone.

In sometimes onchange = “document.formname.submit()” won’t submit the form, while it works on other html pages.

There is hidden truth of this problem is , there may be some other input having the name “submit”. This cause problem in IE and some other browsers. So rename the input field name from submit to any other name (In most case we use the name of submit button as “submit”).

It is a rare tip,  you may  face this someday !!!

Tags: , , , ,

· · · ◊ ◊ ◊ · · ·

Firephp

18 Aug 2009

We like firebug , We like PHP , if so, We also begin to  like FirePHP !!!

Using firephp , you can debug your php code. Firephp is a firefox plugin which works on firebug console.

In our php life, we know we can use echo function to print or debug the value of a variable and we usually do that. But if there is any header function such as image manipulation, redirection etc, if you use echo or print either it leads into unwanted results or we get the common error, cannot modify header information headers already sent  !!!

The one solution for this is, writing the variable value into a log file and check the log file after execution. But the advantage of fire php is, you can log messages, or value of a variable and can see through firebug console.

For example:

<?php $fire_php->log(‘Enter into function’); ?>

<?php $fire_php->log($result); ?>

You can also categorize your error as warning or error . eg:

<?php $fire_php->warn(‘Variable value is not set’)?> or

<?php $fire_php->error(‘No parameter passed’) ?>

For more go to: http://www.firephp.org/

Tags: , , , , , , , ,

· · · ◊ ◊ ◊ · · ·

Google Chrome

03 Sep 2008

10 Features of Google Chrome – Youtube Video

[youtube:http://in.youtube.com/watch?v=Xlh8gSF_hhE]

Yes, a browser with very simple layout. The features i like in this new browser is its full screee view. The only thing in the top area is the location bar. No other menus or buttons or panels are there. It gives a comfort feeling. (All other browsers are very congested )

The Competition is started

Another feature i like to see was that task manager. I was searching for such a plugin in mozilla. Which tabs takes more memory , more internet resources etc. And we can even end the process . Good approach google. Hats off.

The next feature i like is downloading files. It never ask for location for saving. After download you can save as you wish (You can drag the downloaded file anywhere in your computer ). So when you want to download , just download it !!!

On the very first day, i got a crashed warning message from chrome while i browsing !!!

Google Chrome Crashed

But there was option to restart, so saved  all the tabs.

Another feature i liked is it error display mechanism. It shows proper error and proper solution just like google style :)

Dns Error Chrome

One feature i expect was the warning before closing tabs. When i closed the browser, all the tab get closed without any warning.. I think firefox made me to think like this .

And in option , you can see the saved passwords (without any masking !!!) .  That is a bad feature i think.Lets expect more features in the coming update .

And about wordpress editor; some of the functions of WYSWUG wordpress editor is not working with chrome. I think this is because of the javascript compatibility  .

From a developer angle , i got one more browser to test a webpage  (How it appears after changing the html, javascript and css )

Tags: , , , , , , , ,

· · · ◊ ◊ ◊ · · ·

Blunder I ever made

I was writing a php code to parse images from a particular url . At the begining I used http://www.google.com as a testing url.

When I tested the php code from my local machine (http://localhost) it took time to get data from a remote url (google.com) . So I decided to check this code with my locally testing web page. So i write the code as bellow :

file: index.php

<?php

$content = file_get_contents(“http://localhost/”);

// parse($content);

?>

This is the biggest mistake I made that day. Did you find the mistake ?? Else try this code with your local machine. You can see your big blunder . Not only you, your system also will get hang .. :)

Because this is the longest recursive call you can call with your web server !!!

Regards

Sajith

Tags: , , , , , ,

· · · ◊ ◊ ◊ · · ·

وظائف 2011 تحويل العملات برامج برنامج تسريع التحميل برنامج الفلاش برنامج محول الصوتيات عربي hotel 2011 زيادة رواتب العساكر 1431