JavaScript - Facebook Fql Query Pass It To Javascript Array
i am developing a facebook application and i have this code here which queries the user id and other information:
Code: $users = $facebook->api(array('method' => 'fql.query', 'query' => "SELECT uid, last_name, pic_big FROM user WHERE uid IN( SELECT uid FROM page_fan WHERE page_id='411133928921438' AND uid IN ( SELECT uid2 FROM friend WHERE uid1 = me() ))")); I need to store the user id in an array so i can send invitation only to the users in the array generated. Code: function newInvite(){ var user_ids = ["1368246891", "1206927311", "1149862205"]; FB.ui({ method: 'apprequests', message: 'There goes the message for Penelope App users to invite their friends', to: user_ids, }); } THe user_ids must be the array which holds the user id genrated from the fql query... Help me with this... Similar TutorialsBasically I am trying to retrieve my image path data from mysql to my variable created in my javascript. This is the code I m using. <?php $result = mysql_query("SELECT * FROM Shop"); while($row = mysql_fetch_array($result)) { $shopName[] = $row['ShopName']; $shopLogo[] = $row['ShopLogo']; $shopDescription[] = $row['ShopDescription']; $totalShops = count($shopName); } for($i=0; $i<totalShops; $i++){ echo "<script type='text/javascript'>"; echo "var logos = new Array();" echo "</SCRIPT>"; } ?> However, I cant solve the for loop part. I wanted to pass each and every data retrieved from mysql query into the array created in javascript part inside the for loop. Can anyone teach me how to do that? Thanks. hello all, I am new to javascript, i just wanted to know how can i send a array from perl to javascript function.... if anybody having any idea about this please reply me..thanks in adbvance Hi everyone, i am developing a facebook application and here i am, struggling with this piece of code. I have this php query result he $id = $facebook->api(array('method' => 'fql.query', 'query' => "SELECT uid FROM user WHERE uid IN( SELECT uid FROM page_fan WHERE page_id='411133928921438' AND uid IN ( SELECT uid2 FROM friend WHERE uid1 = me() ))")); And i need to save it as an array like: var user_ids = [x,y,z] etc etc... I have used the json_encode but it isn't working... here is my code.. Code: var user_ids = <?php echo json_encode($id); ?>; How can i retrieve the query results, the id's in an array like i mentioned above? Please help me... So my mom owns a business and has a facebook page (for her business.) I want to know how to create a javascript that will make anyone who views her facebook page automatically like it. Is this illegal? Can anyone help? x em-jay x PLEASE IGNORE - I'D DONE A BOO BOO! </facepalm> Hi guys, not sure i have a decent explanation in the title. so, let me explain. i have a script that collapses rows in tables but i create the array in php. the button needs to be above the content else i could just create it using php if i try this function in a .js file it all works: Code: function toggleAll() { //collapse all layers in var togglelist = "['380','379','378','377','376','374','373','369','367']"; for (var i=0; i<togglelist.length; i++) { collapseTableRows(togglelist[i]); } } the problem is that i need to create togglelist when im doing the php. if i just do a simple: Code: <script> var togglelist = "['380','379','378','377','376','374','373','369','367']"; </script> at the bottom of the page i cant seem to pass togglelist to the function in the .js file im a bit rusty at JS so i think im doing something wrong. or is it just that i cant pass a variable array to a function if the variable is below the function on the page... i hope that makes sense. Hi All, Im looking for someone that is great with java script and facebook i have a java app right now i want to add the feature to post to friends walls and so i can change that number as well so if someone clicks on the app the script all ready post to there wall but i want it to post to 15 - 25 of there friends walls over even all friends walls as well. Need these added asap i do have some java that does this all ready just need it added to the script Thanks First time poster. so be kind Hi All, I have found a bit of shared code on the net that can be used on Facebook. The way it is used is on profiles, or groups, that extend beyond an original page. You load the page and then paste the script into the address bar (in FF and chrome) and hit enter. This then goes down and looks for the 'older post' tag and expands it every 4 seconds. When it gets to the end of the group, it does not stop, it just goes into a loop and restarts from the beginning. I am wanting help to get it to stop at the end of the first pass. This is the code: Code: javascript:function clrt(){alert('Stopped Post Load');if(f_sM){clearTimeout(f_sM);}};function showMore(){ProfileStream.getInstance().showMore();f_sM = setTimeout(showMore, 4000); xsm=document.getElementById('profile_pager_container');xsm.addEventListener('click',clrt,false)}; showMore(); I have also seen it done, with the same looping results, with this code: Code: javascript:function showMore() {ProfileStream.getInstance().showMore(); setTimeout(showMore, 4000)} showMore(); Can anyone help please? Thanks Hello, Im hoping someone can help me, Im trying to pass fields to a javascript function that will check the value of each field and it its empty then it will turn the field color red which is what its doing at the moment, but i want to be able to use this function globaly through out my project, so is there a way of not saying how many fields go in to that array, it will just deal with the amount of fields it gets passed? Thanks Code: <html> <head> <title>Variable - Examples 1</title> <script type="text/javascript"> function Student(firstName, lastName, email, courseID, titleArray, pointsArray){ this.firstName = firstName; this.lastName = lastName; this.email = email; this.courseID = courseID; this.title = titleArray; this.points = pointsArray; this.assign = this.points.slice(0,4); this.exams = this.points.slice(-2); this.assignments = function() { return task(this.title,this.points); } this.totalPoints = function() {return addExam(this.assign,this.exams); } this.finalGrade = calcGrade; } Student.prototype = { constructor : Student, toString : studentInfo }; //assign and exam doesn't seem to hold no values inside.. ??? function addExam(assign,exams){ var exams=this.exams; var high1=exams[0]; var high2=0; while(high2<exams.length){ high1=Math.max(high1,exams[high2]); high2++; } var sum = 0; for (var i=0; i < assign.length; i++){ sum += assign[i]; } return sum + high1; } var totalPoints = addExam(); function calcGrade(){ var grade; if (totalPoints >= 190){ return "A+"; }else if (totalPoints >= 180){ return "A"; }else if (totalPoints >= 175){ return "B+" }else if (totalPoints >= 170){ return "B"; }else if (totalPoints >= 165){ return "B-"; }else if (totalPoints >= 160){ return "C"; }else if (totalPoints >= 150){ return "D"; }else if (totalPoints < 150){ return "F"; } } function studentInfo(){ return "Student : " + this.lastName + "," + this.firstName + "<br>"+ "eMail : " + this.email + "<br>" + "Course ID : " + this.courseID + "<br>" + "--------------------------------" + "<br>" + this.assignments() + "--------------------------------" + "<br>" + "Total Points : " + this.totalPoints() + "<br>" + "Final Grade : " + this.finalGrade(); } function createStudents(){ var student1 = new Student("Jake", "Hennry", "jhennery@gmail.com","COIN-070B.01", ["Assignment1","Assignment2","Assignment3","Assignment4","Assignment5","MidTerm", "Final"], [25, 25, 28, 20, 29, 40, 40] ); alert("Student : " + student1.lastName + "," + student1.firstName + "\n"+ "eMail : " + student1.email + "\n" + "Course ID : " + student1.courseID + "\n" + "---------------------------------------" + "\n" + student1.assignments() + "\n" + "---------------------------------------" + "\n" + "Total Points : " + student1.totalPoints() + "\n" + "Final Grade : " + student1.finalGrade()); } var titleArray = ["Assignment1","Assignment2","Assignment3","Assignment4","Assignment5","MidTerm", "Final"]; var pointsArray = [30, 30, 28, 27, 29, 41, 45]; var student = new Student("Haripriyaa", "Ganesan", "haripriyaa@gmail.com","COIN-070B.01", titleArray, pointsArray ); </script> </head> <body> <script type="text/javascript"> document.writeln(student.toString()); </script> </body> </html> I have the two following code snips im working with... <script type="text/javascript"> var url=document.location.href; document.write(url) </script> & the facebook comments box code: <div class="fb-comments" data-href="url" data-num-posts="20" data-width="550" data-colorscheme="dark"></div> I for the life of me cant figure out how to get the variable "url" into the href for the FB comment box. I'd like to do this so no matter what page the complete code is placed on it knows what page to associate the box with, without individual page editing. I'm new to javascript and can generally do some research and figure out what im doig but this has me baffled :| If anyone has the answer it would be GREATLY appreciated!! Thanks in advance :) Hey guys, I have this site http://free-documentaries-online.com . If you go to any documentary page and look under the documentary you will see 'Share this documentary:' like the picture below. I was wondering if you could make all the pictures have a similar size image? facebook.jpg, twitter.jpg, linkedin.jpg, digg.jpg, stumbleupon.jpg, delicious.jpg Here is the code: Code: <a href="http://twitter.com/share" class="twitter-share-button" data-count="none" data-via="freedocosonline">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script> <script src="http://www.stumbleupon.com/hostedbadge.php?s=4"></script> <a href="http://www.delicious.com/save" onclick="window.open('http://www.delicious.com/save?v=5&noui&jump=close&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title), 'delicious','toolbar=no,width=550,height=550'); return false;"> <img src="http://free-documentaries-online.com/images/delicious.jpg" width="20" height="20" alt="Delicious" title="Add to Delicious!" /></a> <script type="text/javascript"> (function() { var s = document.createElement('SCRIPT'), s1 = document.getElementsByTagName('SCRIPT')[0]; s.type = 'text/javascript'; s.async = true; s.src = 'http://widgets.digg.com/buttons.js'; s1.parentNode.insertBefore(s, s1); })(); </script> <a class="DiggThisButton DiggIcon"></a> <a rel="nofollow" target="_blank" href='http://www.facebook.com/sharer.php?u=http://free-documentaries-online.com/watch/index?watch=<? echo "$foldername"; ?>'> <img border="0" src="../images/facebook.jpg" width="20" height="20"></a> <script type="text/javascript" src="http://platform.linkedin.com/in.js"></script><script type="in/share"></script></center> Thanks in advance I have this script added to a facebook icon (#id) on my front page: (function() { var e = document.createElement('script'); e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; e.async = true; document.getElementById('fb-root').appendChild(e); })(); window.fbAsyncInit = function() { var fbClicked = false; FB.init({appId: 'Myappid', status: true, cookie: true, xfbml: true}); FB.Event.subscribe('auth.login', function(response) { if(response.session && fbClicked){ window.location = 'http://www.mysite.com/facebookauth/?ref=/'; } }); } function thFBShortCut() { FB.login(function(response) { fbClicked = true; if (response.session && response.perms && fbClicked) { window.location = 'http://www.mysite.com/facebookauth/?ref=/'; } }, {perms:'email,publish_stream'}); } function thFBLogin() { fbClicked = true; $('.popbox').fadeOut(); FB.getLoginStatus(function(response) { if(response.session && response.status == 'connected' && fbClicked) { window.location = 'http://www.mysite.com/facebookauth/?ref=/'; } }); } I want when whenever user press on facebook icon, the script should trigger facebook connect app. I added `<div id="fb-root"></div>` right after `<body <?php body_class(); ?>>`, but when I load my site I keep getting these error messages: document.getElementById("fb-root") is null and FB is not defined [Break On This Error] FB.login(function(response) { My html: <a id="facebookicon" onclick="thFBShortCut()">Login</a> Here is my code <script language="javascript" type="text/javascript"> function revealModal(divID) { window.onscroll = function () { document.getElementById(divID).style.top = document.body.scrollTop; }; document.getElementById(divID).style.display = "block"; document.getElementById(divID).style.top = document.body.scrollTop; } function hideModal(divID) { document.getElementById(divID).style.display = "none"; } </script> <div id="modalPage3"> <div class="modalBackground"></div> <div class="modalContainer"> <div class="modal53"> <div class="modalTop"><a href="javascript:hideModal('modalPage3')">[X]</a></div> <div class="modalBody"> <?php echo 'value='.$_SERVER['value']; ?> <h3><center>Choose from the options below</center></h3> <center><div id="stylized" class="myform"> <a href="javascript:hideModal('modalPage3');javascript:revealModal('modalPage1')" tabindex="2" title="Remove UPCAT Passer"><img src="images/photo_remove.png" /></a> <a href="javascript:hideModal('modalPage3');javascript:revealModal('modalPage2')" tabindex="4" title="Edit UPCAT Passer"><img src="images/photo_edit.png" /></a> <a href="javascript:hideModal('modalPage3');javascript:revealModal('modalPage4')" tabindex="4" title="Change Status of UPCAT Passer"><img src="images/photo_up.png" /></a> </div></center> </div> </div> </div> </div> <a href=javascript:revealModal('modalPage3');> <img src=images/option.jpg /></a> my problem is this one..how can I pass a value example value=3 to be like href= index.php?value=3..PLEASE HELP!!! I'm using a geolocator service to find the zipcode of a web page visitor using the code below. This will be used to serve up ads to the visitor based on their zip code. The question is, how do I pass the zip code value from the script into an ASP variable, such as a cookie or session object? <script language="JavaScript" src="http://www.iplocationtools.com/iplocationtools.js?key=my_site_key"></script> <script language="JavaScript"> <!-- document.write(ip2location_zip_code()); //--> </script> hi in javascript section there is a variable namesd first is available. i want to pass the value of this variable in a php variable. how can i do this.. Hello Guys, I need some help here.. I have a page that has a grid on it and I have a hidden div(below the grid). When the link is clicked inside the grid it opens the hidden div using the following code for the link in the grid. Here is my code with the PHP id that I need to pass PHP Code: foreach($ct->data as $key => $value){ $ct->data[$key][3]='<a href=#" onclick="part2('.$ct->data[$key][0].');" href="javascript:void();">'.$ct->data[$key][3].'</a>'; Here is the code in my head Code: <script type="text/javascript"> function part2(id) { var part2 = document.getElementById('part2'); if ( part2.className == 'hidden' ) { part2.className = 'visible'; document.getElementById('message').InnerHTML = 'This is the ID: '+id } else { part2.className = 'hidden'; } } </script> Added this to my hidden div to show the id Code: <span id=message></span> Any help would be appreciated.. Thanks, Dan Hey there, I'm using the service from Maxmind to get user's postal code, what I wanna do is pass the value to the next page using GET function.. I am quite new to PHP, however I think I should name the variable first and call it on the next page right? But it doesn't seem to work. Any help is much appreciated! Thanks! i am trying to pass the a variable "oneone" from a select box to a php page via java script. this is my html Code: <div id="wrapper"> <div id="content"> <form> Select a Customer: <select id="oneone" name="oneone" value=""> <option value="s_last">last</option> <option value="s_first ">first</option> <option value="c_city">cirty</option> </select> </form> <div> <form method="get" action="" class="asholder"> <small style="float:right">Hidden ID Field: <input type="text" id="testid" value="" style="font-size: 10px; width: 20px;" disabled="disabled" /></small> <label for="testinput">Person</label> <input style="width: 200px" type="text" id="testinput" value="" /> <input type="submit" value="submit" /> </form> </div> </div> this is my javascript Code: <script type="text/javascript"> var options = { script:"test.php?json=true&limit=6&", varname:"input", json:true, shownoresults:false, maxresults:6, callback: function (obj) { document.getElementById('testid').value = obj.id; } }; var as_json = new bsn.AutoSuggest('testinput', options); var optionsa = { script:"test.php?", varname:"one", json:false }; var as_jsona = new bsn.AutoSuggest('oneone', optionsa); </script> and the little part of my php Code: $input =$_GET['input']; $q =$_GET["one"]; can someone PLEASE tell my why i cant get this to work!!! I'm trying to echo a php variable to my javascript function but nothing is happening Basically this php page displays bunch of records with a radio button next to each record. So when the radio button is clicked it would open that record in a new window that is clicked. Code: <input type='radio' name='option' value='$ctr' id='$ctr' onClick="edit_record('<?php echo $ctr ?>')"> <script type="text/javascript"> function edit_record(){ var value = arguements[0]; alert("record id: " + value); window.open("Edit.php", "Edit Record", "status=1, height=400, width=900, resizable=0"); } Hi, I am trying to implement something like a javascript that can click and focus the Status Update Box on Facebook. Till now, I have nothing in hand that can perform the task so I thought about a javascript that can do it. I am not even a newbie to javascript but I know that it can perform various complicated tasks on client side. Can anyone here tell me how do I click the Status Update box and set it to focused by a javascript so that when I start typing the Status box receive the text ? Thanks |