Showing posts with label Facebook. Show all posts
Showing posts with label Facebook. Show all posts

Thursday, May 30, 2013

Facebook: Tools that can help us

Well basically, playing or working can ended up to be pretty annoying, but luckily there are all sorts of tools to help us to reduce some of the workload.

There's the 'Graph API Explorer' that can help us to figure out the correct commands to use.

* Click here for the 'Graph API Explorer'.

There's the 'Facebook API Reference' that tell us what are the commands that are available.

* Click here for the 'Facebook API Reference'.

There are also all sorts of tools that can help us to cipher/format the big chunk of JSON data into something readable.

* Click here for the website 'Json Parser Online'.
^ Click here for the website 'JSON Editor Online'.
~ Click here for the software 'JSON Viewer'.

Saturday, May 4, 2013

Facebook: Symbols and Emotions

Facebook, one of the biggest social networking website in the world with more than 1 billion users across the globe. From time to time, you will/might be coming across numerous situation where posting an image is much more appropriate than typing a big chunk of text. But how do all the users out there do it?

Well basically, it seems that there are numerous websites that helps us to create all these cute and interesting symbols and emotions for your comments and chats. The following are some examples of such websites. Do take a look. I personally find them pretty interesting. :D


Saturday, April 13, 2013

FB + Adobe AIR: Posting Bug

My friends were asking me to help them to debug an interest problem that they are facing with the Facebook Graph Desktop API.

The scenario as follows. A user log in to the desktop application (Adobe AIR) through Facebook and he decided to post something on his Facebook wall through the application and decides to log out of the Facebook and Application. If a second user tries to log in and post something to his Facebook wall using the application, the message will appear on the wall on the first user, rather than the second user. Therefore here's a fix to that issue if you are using the source files of the 'Facebook Graph Desktop API'.
You have to modify the following function of the following file - com\facebook\graph\FacebookDesktop.as From
    public static function api(method:String,
                     callback:Function,
                     params:* = null,
                     requestMethod:String = 'GET'
    ):void {
      getInstance().api(method,
        callback,
        params,
        requestMethod
      );
    }
To
    public static function api(method:String,
                     callback:Function,
                     params:* = null,
                     requestMethod:String = 'GET'
    ):void {

      if(params != null)
      {
        if (getInstance().session != null) {
          params.access_token = getInstance().session.accessToken;
        }
      }
      getInstance().api(method,
        callback,
        params,
        requestMethod
      );
    }
* Click here for the updated file 'FacebookDesktop.as'.
^ Click here to find out more about the 'Facebook Graph Desktop API'.

Friday, September 21, 2012

FB + Adobe AIR: Logout Bug

A question was thrown at me the other day, regarding the issue of successfully logging out of FB on a Adobe AIR application. It seems that the Facebook Graph Desktop API has a bug. If a user has successfully log in to FB through the Adobe AIR application, the username and the password will be stored somewhere. Even after the user has log out of FB, the username and the password isn't cleared by the application and when another user tries to log in through the same application on the same machine, rather than prompting the user to enter his username and password, the application will log in automatically using the last set of username and password that are working perfectly. After spending a bit of time playing with it, I managed to find a workaround for this bug.

Rather than doing the following,
 //Rather than using the logout function of the API,
 //you need to add some more codes to it.
 FacebookDesktop.logout(handleLogout, APP_ORIGIN);

You need to add a few more lines to log out properly.
 /*
  All the following liners are required to logout successfully.
 */
 var uri:String = APP_ORIGIN;
 var params:URLVariables = new URLVariables();
 params.next = uri;
 params.access_token = FacebookDesktop.getSession().accessToken;
     
 var req:URLRequest = new URLRequest("https://www.facebook.com/logout.php");
 req.method = URLRequestMethod.GET;
 req.data = params;
     
 var netLoader:URLLoader = new URLLoader();
 netLoader.load(req);
     
 FacebookDesktop.logout(handleLogout, APP_ORIGIN);
* Click here to play with the Adobe AIR application.
^ Click here to take a look at the source files that I'm playing with.
~ Click here to find out more about the Facebook Graph Desktop API.

Friday, May 4, 2012

Flash as3: Multiple Facebook Image Upload

Someone was asking me how to upload numerous images into Facebook the other day, hence I decided to give it a try. I was trying out Batching using the 'GraphAPI_Web_1_8_1.swc' Library but it seems to be broken for uploading a series of images. Hence, I have created a simple workaround for uploading multiple images.


* Click here to take a look at the example that I had created.
^ Click here for the source files of the example that I had created.

Wednesday, August 31, 2011

Dynamic meta Description, meta Keywords and Title using PHP

Changing your the meta description, meta keywords and title of a php page.This is a follow up of a post that I had posted here a few weeks back.


I only make some changes to the header.php file and the header.php file will handle the value of $section and change the title, the meta description and meta keywords of the webpage.
<?
	//Conditional Statement to change the title, meta description and meta keywords.
	if ($section == "home"){
		$title = "Unique title for home page";
		$description = "A Unique description for 'Home' Section";
		$keyword = "Home";
	}else if ($section == "profile"){
		$title = "Special title for profile page";
		$description = "A Special description for 'Profile' Section";
		$keyword = "Profile";
	}else if ($section == "product"){
		//Another Conditional Statement to change the title, meta description and meta keywords base on the productID.
		$productID = $_REQUEST["productID"];
		if($productID == "x"){
			$title = "Product page for X";
			$description = "A description for 'Product X'";
			$keyword = "Product X";
		}else if($productID == "y"){
			$title = "Product page for Y";
			$description = "A description for 'Product Y'";
			$keyword = "Product Y";
		}else if($productID == "z"){
			$title = "Product page for Z";
			$description = "A description for 'Product Z'";
			$keyword = "Product Z";
		}else{
			$title = "A title for product page";
			$description = "A description for 'Product' Section";
			$keyword = "Product X, Product Y, Product Z";
		}
	}else if ($section == "contact"){
		$title = "Contact me now";
		$description = "Form for contact me";
		$keyword = "Conact me, form";
	}
	//Write the title, meta description and meta keywords into a header html tag
	echo "<header>";
	echo "<title>".$title."</title>";
	echo "<meta name='description' content='".$description."'>";
	echo "<meta name='keywords' content='".$keyword."' />"; 
	echo "</header>";
	//Create a table and base on the value os $section, toggle the state of the selected button.
	echo "<table cellpadding='0' cellspacing='0' border='0' width='100%' ><tr>";
	//If $section == home, make the text 'Home' unclickable else makt it into a clickable hyperlink
	if ($section != "home"){
		echo "<td align='center'><a href='home.php'>Home</a></td>";
	}else{
		echo "<td align='center'><b>Home</b></td>";
	}
	//If $section == profile, make the text 'Profile' unclickable else makt it into a clickable hyperlink
	if ($section != "profile"){
		echo "<td align='center'><a href='profile.php'>Profile</a></td>";
	}else{
		echo "<td align='center'><b>Profile</b></td>";
	}
	//If $section == product, make the text 'Product' unclickable else makt it into a clickable hyperlink
	if ($section != "product"){
		echo "<td align='center'><a href='product.php'>Product</a></td>";
	}else{
		echo "<td align='center'><b>Product</b></td>";
	}
	//If $section == contact, make the text 'Contact Us' unclickable else makt it into a clickable hyperlink
	if ($section != "contact"){
		echo "<td align='center'><a href='contact.php'>Contact Us</a></td>";
	}else{
		echo "<td align='center'><b>Contact Us</b></td>";
	}
	echo "</tr></table>";
	echo "<br>";
?>

Click here for the example that I had created for the post.
Try click and copying the following URL1 and URL2 into Facebook and you will see how useful php can be.
Click here for the source codes of the example that I had created.

Sunday, August 7, 2011

Facebook: Changing the description of your websites / blogs

This happen to me quite often in the past. I was building a website or after I had written a new post on one of my blogs, I would immediately copy and paste the URL of the website onto my Facebook wall. Upon doing that, Facebook will show you the title, the description and a series of thumbnail for you to select of the URL that you have pasted. You realise that some parts of the copy were missing due to some illegal characters or you suddenly decided to change the thumbnail of the website. After making that minor change, Facebook will still reflect the same contents as per what you had before you make the minor change. What to do? How to work around this issue?

As long as the same URL have not been shared by any other users, you will still have a way to ask Facebook to update to the latest content.

Click here to move to one of the developer tools that Facebook had created.

Copy and paste the URL that you want to share into the text field and click on the 'Lint' button located next to the text field.

Now, the updated content should be appearing on this webpage and you can start sharing your URL with the correct set of contents now. :)

Note:
  • This method will not work after someone had already started sharing the same URL that you are sharing.
  • If this method doesn't work, create a separate server script scripting file and do a redirect from that file. And share the new URL. :D

Sunday, June 26, 2011

Flash / Facebook: Image Tagging in Facebook using Flash V2 (Updated to v1.8.1)

After spending some time playing around the api of Facebook and Flash AS3, I finally manage to do modify the way of doing Image Tagging of the friends of the user in Facebook using Facebook and Flash AS3. In my previous example, I was making more than 1 calls to the Facebook API in order to do image tagging for the photos in Facebook. But in this example, I had managed to reduce the number of calls to the Facebook API in order to perform the same duties as before.


The only changes that I had made were in the Facebook connection class
that I had created to make things easier for myself to make API calls to Facebook.

Click here to take a look at the example that I had created.
Click here for the source files of the example that I had created.

Thursday, June 16, 2011

Flash / Facebook: Image Tagging in Facebook using Flash (Updated to v1.8.1)

After spending some time playing around the api of Facebook and Flash AS3, I finally manage to do Image Tagging of the friends of the user in Facebook using Facebook and Flash AS3.


Before moving any further, I had used the following api's to get my way around this topic.
  • facebook-actionscript-api: This library is one of the easiest way to work your way around Flash AS3 and Facebook.
  • Facebook - Graph API - Photo: You might want to spend some time understanding the Facebook Graph API for uploading of images, so that you will know what I'm going to cover.

Basically the theory is pretty simple:
  1. You upload an image to Facebook and upon success uploading, store the image id that was return from Facebook.
  2. Based on the image id, send the user id of your friend and the X and Y coordinates of the point you want to tag your friend.
    Note:
    • The X and Y coordinates were actually in percentages ranging from 0 - 100.
    • The parameter name for the friend's user id were actually "to" in the Facebook API. Please refer to the Facebook - Graph API that I had mentioned earlier in this post.

The following will be the actionscript codes of my Main Fla.
package com.FacebookTest{
 //The following are the neccessary imports of AS3 classes
 import com.adobe.serialization.json.JSON;
 //This AS3 class is written by myself for having a connection with Facebook
 import com.util.facebook.FacebookConnect;
 
 import flash.events.Event;
 import flash.events.DataEvent;
 import flash.geom.Point;
 
 public class Main extends InterfaceSetup{  
  //This MovieClip is used to display all my outputs.
  private var resultMC;
  //A reference to my AS3 Facebook Connection Object class
  public var fbConnectRef:FacebookConnect = null;
  
  public function Main(){
   //Call setupBtns() to setup all my movieclip buttons
   setupBtns();
   
   resultMC = results_mc;
   publish_txt.text = "";
   
   //Setting up my Facebook Connection Object
   fbConnectRef = new FacebookConnect();
   //Add a Listener for DataEvent
   fbConnectRef.addEventListener(DataEvent.DATA, fbEvent);
   /*
    Setting up the AS3 Facebook Connection Object
    1st param: Facebook App ID
    2nd param: Width and Height of Flash file as a Point Object
    3rd param: Do you want to show the Facebook Distractor? True / False
    4th param: parent obj of the Facebook Connection Object
   */
   fbConnectRef.setup("123666563282",new Point(300,350),true,this);
  }
  
  //This function will handle all the 'data' of the DataEvent of my AS3 Facebook Connection Object class
  private function fbEvent(event:DataEvent){
   if(event.data == "appLogin_Success"){
    tracer(String(event.data));
   }else if(event.data == "login_Success"){
    tracer(String(event.data));
   }else if(event.data == "login_Failure"){
    tracer(String(event.data));
   }else if(event.data == "logout_Success"){
    tracer(String(event.data));
   }else if(event.data == "logout_Failure"){
    tracer(String(event.data));
   }else if(event.data == "uploadImage_Success"){
    tracer(String(event.data));
    //When image had been uploaded, re-setup all those buttons again
    setupNormBtn(btns_mc.findImage_mc.cover_mc);
    setupNormBtn(btns_mc.publish_mc.cover_mc);
   }else if(event.data == "uploadImage_Failure"){
    tracer(String(event.data));
    //When image had been uploaded, re-setup all those buttons again
    setupNormBtn(btns_mc.findImage_mc.cover_mc);
    setupNormBtn(btns_mc.publish_mc.cover_mc);
   }else if(event.data == "uploadImage_Login"){
    tracer("Error: You need to login to Facebook.");
    //When image had been uploaded, re-setup all those buttons again
    setupNormBtn(btns_mc.findImage_mc.cover_mc);
    setupNormBtn(btns_mc.publish_mc.cover_mc);
   }else if(event.data == "publish_Failure"){
    tracer(String(event.data));
   }else if(event.data == "publish_Success"){
   }else if(event.data == "uploadImage_Found"){
    tracer(String(event.data));
    tracer(fbConnectRef.getResult());
    imgName_txt.text = fbConnectRef.getResult();
   }
  }
  
  //Function to loop through all the MovieClip in the btns_mc and pass it into setupBtn(); 
  private function setupBtns(){
   var tempMC;
   for(var i = 0; i < btns_mc.numChildren; i ++){
    tempMC = btns_mc.getChildAt(i);
    setupBtn(tempMC);
   } 
  }
  
  //Function to label and setup the given MovieClip into a button
  private function setupBtn(mc){
   var nameArray = String(mc.name).split("_");
   mc.text_txt.text = nameArray[0];
   mc.text_txt.autoSize = "left";
   mc.cover_mc.width = mc.bg_mc.width = mc.text_txt.width;
   mc.cover_mc.height = mc.bg_mc.height = mc.text_txt.height;
   setupNormBtn(mc.cover_mc);
  }
  
  //This funcation will handle all the click events of all the buttons
  override public function clickEvent(event:Event){
   if(event.target.name == "cover_mc"){
    if(event.target.parent.text_txt.text == "login"){
     login();
    }else if(event.target.parent.text_txt.text == "logout"){
     fbConnectRef.logout();
    }else if(event.target.parent.text_txt.text == "publish"){
     killNormBtn(btns_mc.findImage_mc.cover_mc);
     killNormBtn(btns_mc.publish_mc.cover_mc);
     //Change if user had enter any userid
     if(isEmpty(publish_txt.text) == false){
      /*
       If user had entered an userid, it will format it into an array.
       The following will be the layout of my XML:
       
        
         123456 //Facebook Profile ID comes here
         10   //The X coordinate of the user on the picture. Value would be ranging from 0-100 percent.
         10  //The Y coordinate of the user on the picture. Value would be ranging from 0-100 percent.
        
        
        .
        .
        .
       
      */
      var tagArray:Array = String(publish_txt.text).split(";");
      var tempXML:XML;
      var tempXMLStr:String = "";
      for(var i = 0; i < tagArray.length; i ++){
       tempXMLStr += "";
       tempXMLStr += "" + tagArray[i] + "";
       tempXMLStr += "" + Math.round(Math.random() * 100) + "";
       tempXMLStr += "" + Math.round(Math.random() * 100) + "";
       tempXMLStr += "";
      }
      tempXMLStr += "";
      tempXML = new XML(tempXMLStr);
      /*
       Sending an request for the uploading of the image and tagging of the users into the image
       1st param: where you want to upload the photo to?
       2nd param: Message / Description of the Image
       3rd param: The XML format of the Userid that I explained earlier.
      */
      fbConnectRef.uploadImage("/photos","Image Upload test",tempXML);
     }else{
      fbConnectRef.uploadImage("/photos","Image Upload test");
     }
    }else if(event.target.parent.text_txt.text == "findImage"){
     //Prompt the AS3 Facebook Connection Object class to look for the image the user wants to upload
     fbConnectRef.findImage();
    }
   }
  }
  
  private function login(){
   //Passing or requesting for the rights or permission of this Facebook App upon the User's login
   fbConnectRef.login("publish_stream,create_event, rsvp_event, sms, offline_access" +
    ", user_about_me, friends_about_me, user_activities, friends_activities, user_birthday" +
    ", friends_birthday, user_education_history, friends_education_history, user_events" +
    ", friends_events, user_groups, friends_groups, user_hometown, friends_hometown, user_interests" +
    ", friends_interests, user_likes, friends_likes, user_location, friends_location, user_notes" +
    ", friends_notes, user_online_presence, friends_online_presence, user_photo_video_tags" +
    ", friends_photo_video_tags, user_photos, friends_photos, user_relationships" +
    ", friends_relationships, user_relationship_details, friends_relationship_details" +
    ", user_religion_politics, friends_religion_politics, user_status, friends_status" +
    ", user_videos, friends_videos, user_website, friends_website, user_work_history" +
    ", friends_work_history, email, read_friendlists, read_insights, read_mailbox" +
    ", read_requests, read_stream, xmpp_login, ads_management, user_checkins, manage_pages");
  }  
  
  //Function to handle all the outputs
  private function tracer(tempStr){
   resultMC.appendText(tempStr + "\n");
   resultMC.verticalScrollPosition = resultMC.maxVerticalScrollPosition;
  }
 }
}

Click here to take a look at the example that I had created.
Click here for the source files of the example that I had created.