Want to show my latest 5 facebook messages on another website of mine??

Discussion in 'PHP' started by 123GoToAndPlay, Mar 15, 2010.

  1. #1
    How can i show/get the latest 5 facebook messages i posted on facebook/twitter???

    I think the developer.facebook would be to much for a simple task like this or am i wrong/?

    And lastly do you know of any other nice facebook integration in own websites or tutorial on the $facebook->api_client->stream_get subject
     
    Last edited: Mar 15, 2010
    123GoToAndPlay, Mar 15, 2010 IP
  2. vinoth.t

    vinoth.t Peon

    Messages:
    156
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can show latest tweets but you can't do it facebook because facebook message is not accessible by public.
    If you want to show your tweets on your webpage just use the below code
    
    <style>
    #twitter_update_list li {list-style-type: none;}
    #twitter_update_list span {color: #000000;background: #E6E6FA;}
    #twitter_update_list span a display: inline;color: #709cb2;}
    #twitter_update_list span a:hover {text-decoration: underline;
    color: #709cb2;}
    </style>
    <div id="twitter_update_list">
    <script type="text/javascript" src="http://twitter.com/javascripts/blogger.js">
    <script type="text/javascript" src="http://twitter.com/statuses/user_timeline/vinoththiru.json?callback=twitterCallback2&;count=1">
    </div>
    
    Code (markup):
    Replace "vinoththiru" with your account name
     
    vinoth.t, Mar 16, 2010 IP
  3. mattinblack

    mattinblack Peon

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yeah you can if your php setup has curl enabled. If you look at the code of the facebook home page you will see two fields named="email" id="pass" and some other fields. Send values for all the fields in the form to the address specified by the form using curls POST facility and you will get back your home page, from which you can scrape the messages. I would suggest that you do not do this every time a page loads but maybe at a random time twice an hour (keep a timer file and write the current time()+1200+rand(1,500) to it then look at this every page load ind if current time()> file value get your messages and save them to a file, if not get the contents of your messages file instead.
     
    mattinblack, Mar 16, 2010 IP
  4. vinoth.t

    vinoth.t Peon

    Messages:
    156
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    When you login they will create a session and set cookie how that can be done in curl
     
    vinoth.t, Mar 16, 2010 IP
  5. GoldenGrahams

    GoldenGrahams Active Member

    Messages:
    137
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #5
    He could also make his profile public, which would save the need to login using curl, simply grab the data using curl from facebook.com/username ?
     
    GoldenGrahams, Mar 16, 2010 IP
  6. mattinblack

    mattinblack Peon

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Think you need to learn more about sessions. If a cookie cannot be created then the system switches to using sessid instead.
     
    mattinblack, Mar 16, 2010 IP
  7. 123GoToAndPlay

    123GoToAndPlay Peon

    Messages:
    669
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #7
    hi guys,

    I have almost got a workable solution. I found this awesome post blog.jylin.com/2009/10/01/loading-wall-posts-using-facebookstream_get/ and it shows how to set your permanent session key.

    Now i have this test to show the latest 5 posts on facebook
    
    	$i=0;
    	foreach($wall['posts'] as $post) {
    		//var_dump($post);
    		echo '<a href="'.$post['permalink'].'" >'.$post['message'].'</a><br/>';
    		$i++;
    		if($i == 5) {
    			break;
    		}
    	}
    
    Code (markup):
    1/ How can i make a cleaner limit foreach???
    2/ What would you display on your own website (just make a var_dump and you see which data you get from facebook)??

    3/ Oh and i have develop a function which shows my latest 3 youtube thumbs + description on my website? any pointers??

    regards
     
    Last edited: Mar 17, 2010
    123GoToAndPlay, Mar 17, 2010 IP