SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    38911 Basic Bytes Free johnuk's Avatar
    Join Date
    Jul 2008
    Location
    Somerset, England
    Posts
    458
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Facebook JDK / Publish Stream Issue

    Hey all,

    I am trying to publish a simple stream to facebook from my clients website, using FB.ui, but when I run the "streamPublish" method holding this code I just get "An error occurred. Please try again later."

    My code is as follows:-

    Code JavaScript:
    <head>
    	<title>A Dynamic Comment System</title>
    	<meta http-equiv="content-type" 
    		content="text/html;charset=utf-8" />
    	<meta http-equiv="Content-Style-Type" content="text/css" />
     
    	<!-- Javascript Librairys -->
    	<script src="http://connect.facebook.net/en_US/all.js"></script>
    	<script type="text/javascript" src="javascripts/commentsystem.js"></script>
     
    	<!-- Style Sheets -->
    	<style type="text/css" media="all">
    		@import "css/commentstyles.css";
    	</style>	
     
    		<script> 
               window.fbAsyncInit = function() { 
    				FB.init({appId: "180166762023187", status: true, cookie: true, 
                    xfbml: true}); 
                }; 
     
    			(function() 
    			{ 
    				var e = document.createElement("script"); e.async = true; 
    				e.src = document.location.protocol + "//connect.facebook.net/en_US/all.js"; 
    				document.getElementById("fb-root").appendChild(e); 
    			}());
     
    			function streamPublish()
    			{       
    				FB.ui(  
    						{   method: 'stream.publish',display:'popup', message: 'getting educated about Facebook Connect', attachment: 
    							{      
    								name: 'Connect', caption: 'The Facebook Connect JavaScript SDK', description: ('A small JavaScript library that allows you to harness ' +  'the power of Facebook, bringing the user\'s identity, ' + 'social graph and distribution power to your site.'),
    								href: 'http://github.com/facebook/connect-js'     
    							},  action_links: [{ text: 'Code', href: 'http://github.com/facebook/connect-js' }],     
    								user_message_prompt: 'Share your thoughts about Connect'  	
    						},   
    						function(response) 
    						{     
    							if (response && response.post_id) 
    							{       
    								alert('Post was published.');     
    							} 
    							else 
    							{       
    								alert('Post was not published.');     
    							}   
    						} );
    			} 
    		 </script>	
    </head>

    I am not all that familiar with the FB API, so I am totally stumped - any help much appreciated !

  2. #2
    38911 Basic Bytes Free johnuk's Avatar
    Join Date
    Jul 2008
    Location
    Somerset, England
    Posts
    458
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh and just for the record, stream.share works! but stream.publish doesent, which is what I need

  3. #3
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    3 Thread(s)
    I try to avoid facebook as much as possible, but you could try over at the facebook platform developers forum
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  4. #4
    38911 Basic Bytes Free johnuk's Avatar
    Join Date
    Jul 2008
    Location
    Somerset, England
    Posts
    458
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello pmw, I appreciate your help - I found out the problem after many hours sat infront the computer. The following block of JS needs to go after the
    Code HTML4Strict:
    <div id="fb-root"></div>
    divs, rather than in the head. Its just a shame there was not mention of this in the FB API documentation - onwards and upwards

    Code JavaScript:
    <div id="fb-root"></div>   
    	<script>
    			(function() 
    			{ 
    				var e = document.createElement("script"); e.async = true; 
    				e.src = document.location.protocol + "//connect.facebook.net/en_US/all.js"; 
    				document.getElementById("fb-root").appendChild(e); 
    			}());
    	</script>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •