Jump to content

Mancent

Members
  • Posts

    147
  • Joined

  • Last visited

Everything posted by Mancent

  1. Problem Solved! you guys can have it! http://claritydreams.com/youtube/search.php?SreachName=Staind <?php $SreachName = $_GET['SreachName']; if(empty($SreachName)) { echo "No Search"; return true; } // set feed URL $feedURL = 'https://gdata.youtube.com/feeds/api/videos?q='.$SreachName; // read feed into SimpleXML object $sxml = simplexml_load_file($feedURL); // echo $sxml->title; $youtube_xml = "<?xml version=\"1.0\"?>\n"; $youtube_xml .= "<root>\n"; $youtube_xml .= "<youtube>\n"; // iterate over entries in feed foreach ($sxml->entry as $entry) { // get nodes in media: namespace for media information $media = $entry->children('http://search.yahoo.com/mrss/'); // get video player URL $attrs = $media->group->player->attributes(); $watch = $attrs['url']; // get video thumbnail $attrs = $media->group->thumbnail[0]->attributes(); $thumbnail = $attrs['url']; // get <yt:duration> node for video length $yt = $media->children('http://gdata.youtube.com/schemas/2007'); $attrs = $yt->duration->attributes(); $length = $attrs['seconds']; // get <yt:stats> node for viewer statistics $yt = $entry->children('http://gdata.youtube.com/schemas/2007'); $attrs = $yt->statistics->attributes(); $viewCount = $attrs['viewCount']; // get <gd:rating> node for video ratings $gd = $entry->children('http://schemas.google.com/g/2005'); if ($gd->rating) { $attrs = $gd->rating->attributes(); $rating = $attrs['average']; } else { $rating = 0; } $youtube_xml .= "<watch>" . $watch . "</watch>\n"; $youtube_xml .= "<grouptitle>" . $media->group->title . "</grouptitle>\n"; $youtube_xml .= "<groupdiscription>" . $media->group->description . "</groupdiscription>\n"; $youtube_xml .= "<thumbnail>" . $thumbnail . "</thumbnail>\n"; $youtube_xml .= "<name>" . $entry->author->name. "</name>\n"; $youtube_xml .= "<views>" . $viewCount. "</views>\n"; $youtube_xml .= "<rating>" . $rating. "</rating>\n"; } $youtube_xml .= "</youtube>\n"; $youtube_xml .= "</root>\n"; echo $youtube_xml; ?>
  2. I am wanting to write a script that will allow a user to search youtube videos! What I have so far is not working yet, but I know it can be done! I found this code and it works and its not a million api files to get one thing working! <?php # YouTube Video Collector - YouTube.class.php ##################################################### # # # YouTube Video Collector 2010 # # # # Author: CMBSystems (Chris Bearcroft) # # Copyright: CMBSystems 2010, All Rights Reserved # # Last Modded: 29-09-2010, 1:26 AM (GMT) # # # ##################################################### class YouTube { public function getURL($Search){ if(!empty($Search)){ $Search=split("\n",$Search); for($i=0;$i<count($Search);$i++){ $SearchURL=urlencode($Search[$i]); $SearchURL="http://www.youtube.com/results?search_category=10&search_type=videos&search_query={$SearchURL}"; preg_match('/\/watch\?v=(.*?)\"/',file_get_contents($SearchURL),$URL); if(strpos($URL[1],'&')){$URL=split('&',$URL[1]);$URL=$URL[0];}else{$URL=$URL[1];} $array[]="http://www.youtube.com/watch?v={$URL}"; } return $array; } } public function printForm($Search){ $Search=htmlspecialchars(stripslashes($Search)); return "<form method=\"get\" action=\"\">\n <table>\n <tr>\n". " <td><textarea cols=\"60\" rows=\"15\" name=\"search_query\">{$Search}</textarea></td>\n". " </tr>\n <tr>\n <td align=\"right\"><input type=\"submit\" value=\"Search YouTube\" /></td>\n". " </tr>\n </table>\n</form>\n"; } } ?> <?php # YouTube Video Collector - YouTube.php ##################################################### # # # YouTube Video Collector 2010 # # # # Author: CMBSystems (Chris Bearcroft) # # Copyright: CMBSystems 2010, All Rights Reserved # # Last Modded: 29-09-2010, 1:26 AM (GMT) # # # ##################################################### # Require the YouTube class require 'YouTube.class.php'; # Set the PHP vars $Form = YouTube::printForm($_GET['search_query']); $Result = YouTube::getURL($_GET['search_query']); print <<<YTVSC <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>YouTube Collector</title> </head> <body> {$Form} YTVSC; print_r($Result); print <<<YTVSC </body> </html> YTVSC; ?> It allows me to have a feed link on my site to get the data http://claritydreams.com/youtube/YouTube.php?YT_Search=Staind I can push that ?YT_Search as a search from with in my client but I want to convert the file in to xml to read the data back into the client.
  3. Thank you guys you have been a really big help But however i have not yet had any luck getting it to work, more errors. so my mind just is not getting it yet!
  4. Any example: You can give,, the array has json, and I am converting it to xml, so the file product would be a xml, How can I do that? Could you show me?
  5. <?php if(!empty($_FILE)){ $target = "upload/"; $target = $target . basename( $_FILES['uploaded']['name']) ; $ok=1; //This is our size condition if ($uploaded_size > 350000) { echo "Your file is too large.<br>"; $ok=0; } //This is our limit file type condition if ($uploaded_type =="text/php") { echo "No PHP files<br>"; $ok=0; } //Here we check that $ok was not set to 0 by an error if ($ok==0) { Echo "Sorry your file was not uploaded"; } //If everything is ok we try to upload it else { if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else { echo "Sorry, there was a problem uploading your file."; } } } is correct just add that to the top of the script and then do a else else { //the email system /* this part can either be in the same file as the form or it can be in a different file. If you want this in a different file, make the "action" of the form go to that file */ if(sizeof($_POST)) { $body = ""; while(list($key, $val) = each($HTTP_POST_VARS)) { $body .= "$key: $val \n"; } mail("xx@xx.com", // to "Resume", $body, "From:".$Email); } // end form processing } ?>
  6. Im sorry I am very new with arrays But I am interested in learning on this one. I think once I see the fix I will understand it, I know its something simple i just can not find what i am looking for.
  7. Warning: SimpleXMLElement::addChild() [simplexmlelement.addchild]: unterminated entity reference limit=50&method=GET&access_token=AAACd5Mcn7VQBAKaupEZCocujRuoBzzWeZCj945ZApHEsv5BZAxZCJfS62cSSz4txlZBUZAec03GcjpHdk0NTotnglt2ZB41GzzeYl8xqIZBmsvlS6UZAoHZB1A4&offset=50 in /home/content/71/8432771/html/facebook/get/friends.php on line 62 <?php /** * Copyright 2011 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. You may obtain * a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations * under the License. */ require '../../src/facebook.php'; // Create our Application instance (replace this with your appId and secret). $facebook = new Facebook(array( 'appId' => 'APPID', 'secret' => 'SECRET', )); // Get User ID $user = $facebook->getUser(); // We may or may not have this data based on whether the user is logged in. // // If we have a $user id here, it means we know the user is logged into // Facebook, but we don't know if the access token is valid. An access // token is invalid if the user logged out of Facebook. if ($user) { try { // Proceed knowing you have a logged in user who's authenticated. $user_profile = $facebook->api('/me/friends?fields=id,name,first_name,last_name,picture&limit=50'); } catch (FacebookApiException $e) { error_log($e); $user = null; } } // Login or logout url will be needed depending on current user state. if ($user) { $logoutUrl = $facebook->getLogoutUrl(); } else { $loginUrl = $facebook->getLoginUrl(); } $profile = array ($user_profile); $xml = new SimpleXMLElement('<root/>'); arrayToXML( $xml, $profile ); echo $xml->asXML(); function arrayToXML( SimpleXMLElement &$xml, $array ) { foreach( $array as $name => $value ) { if( !is_array($value) ) $xml->addChild( $name, $value ); else { $child = $xml->addChild( $name ); <----------------------------------------------LINE 64 arrayToXML( $child, $value ); } } } ?> Here is the array { "data": [ { "name": "Pauline Latty", "id": "312293" }, { "name": "Noah Ethan Schinasi", "id": "55101245" }, { "name": "Luis Guerrero", "id": "194803212" }, { "name": "Nakia Johnson", "id": "500350828" }, { "name": "Bethany Vallerie", "id": "502062429" }, { "name": "Caroline Franks", "id": "505331027" }, { "name": "Andrew Shivers", "id": "505749817" }, { "name": "Sandra G Garcia", "id": "508006303" }, { "name": "Catherine Davis", "id": "511006416" }, { "name": "Marc Watson", "id": "511201074" }, { "name": "Laura Clarke", "id": "513653820" }, { "name": "Amanda Rice", "id": "514062403" }, { "name": "Scott Alan Buss", "id": "514197867" }, { "name": "Evangelist Josephus", "id": "515837621" }, { "name": "Chet Fontenot", "id": "516199085" }, { "name": "Sharon Howard", "id": "516580144" }, { "name": "Chatt Franco", "id": "517211511" }, { "name": "Lydgia Vanessa Staples", "id": "518094760" }, { "name": "Corry Bell", "id": "521043483" }, { "name": "Lessie Tyson", "id": "521855454" }, { "name": "Jawahar Peter", "id": "523159934" }, { "name": "Sheena Shiko", "id": "523461577" }, { "name": "Pat Larry Thomas", "id": "523555768" }, { "name": "Oyenuga Kunle Johnson Matthew", "id": "524263978" }, { "name": "Angela Whitten", "id": "524631356" } ], "paging": { "next": "https://graph.facebook.com/me/friends?limit=25&access_token=2227470867|2.AQAMMvJya05xkLhR.3600.1318057200.0-100001957015772|IUAhNlekyalf7sxy-OjdJd7KCwo&offset=25" } } its that paging, I can not seem to get that to work yet.
  8. so this is correct If(!empty() $UserId) { //so this says that if the variable is empty it will run this condition? }
  9. //THIS HERE IS WHAT I AM HAVING A PROBLEM WITH, IF STATEMENT STATING THAT IF $UserId IS EMPTY AND THE OTHER VARIABLES RETURN NOTHING BUT IF IS HAS A VALUE IT INSERTS //IF(!empty $UserId) { //something to do here! }
  10. Sorry thought php bbcode was what i should use.. HA HA my bad fixed
  11. This is old script I messed up big time using username as the folder location should have used ID numbers only
  12. The Upload.php <?php Header('Cache-Control: no-cache'); Header('Pragma: no-cache'); include "../../connect.php"; include('Resize.php'); $username = mysql_real_escape_string($_GET['username']); if( $username) { echo $username; $root ="../../../users/"; $folder ="/images/"; $folder1 ="pictures/"; $folder2 ="thumb/"; $filepath =$root.$username.$folder.$folder1; $filepath1 =$root.$username.$folder.$folder1.$folder2; if(!file_exists($root)) { mkdir($root,0777); chmod($root,0777); } if(!file_exists($root.$username)) { mkdir($root.$username,0777); chmod($root.$username,0777); } if(!file_exists($root.$username.$folder)) { mkdir($root.$username.$folder,0777); chmod($root.$username.$folder,0777); } if(!file_exists($root.$username.$folder.$folder1)) { mkdir($root.$username.$folder.$folder1,0777); chmod($root.$username.$folder.$folder1,0777); } if(!file_exists($root.$username.$folder.$folder1.$folder2)) { mkdir($root.$username.$folder.$folder1.$folder2,0777); chmod($root.$username.$folder.$folder1.$folder2,0777); } if(!file_exists($filepath)) { mkdir($filepath,0777); chmod($filepath,0777); } if(!file_exists($filepath1)) { mkdir($filepath1,0777); chmod($filepath1,0777); } $filetempname=$_FILES['Filedata']['tmp_name']; $ext =".wsi"; $filename=md5(md5($filetempname)).$ext; $folder3 ="_Pictures"; $userfolder2 =$username.$folder3; //Ok let resize thie image to be small $image=new SimpleImage(); $image->load($filetempname); $image->resize(100,100); $image->save($filepath1.$filename); $image=new SimpleImage(); $image->load($filetempname); $image->resize(1900,1000); $image->save($filepath.$filename); //SELECT WHERE AND FOLDER IF RETURN 0 INSERT INTO ELSE RUN THE REST NO UPDATE IS REQUIRED. $get_username_and_folder = "SELECT * FROM user_image_folders WHERE username = '$username' AND user_folder='$userfolder2'"; $username_folder_results = mysql_query($get_username_and_folder) or die("Data not found."); //Get the number of results from the query. $check_username_and_folder = mysql_num_rows($username_folder_results); if($check_username_and_folder == 0) { $setuserfolder23 = mysql_query("INSERT INTO user_image_folders(username,user_folder) VALUES ('$username','$userfolder2')") or die(mysql_error()); } $timeanddate = date("l, F d, Y h:i" ,time()); //$setuseravatar= mysql_query("UPDATE accounts SET background = 'http://wiistream.info/users/$username/images/background/$filename' WHERE username = '$username'"); $setuserfolder3 = mysql_query("INSERT INTO user_photo_gallery (username,user_folder,large_pic,small_pic,pic_title,pic_discription) VALUES ('$username','$userfolder2', 'http://wiistream.info/users/$username/images/pictures/$filename','http://wiistream.info/users/$username/images/pictures/thumb/$filename','$userfolder2','$userfolder2')") or die(mysql_error()); $setuserfolder = mysql_query("INSERT INTO user_comments (username,comment,timestamp,title,picture,pic_status,pic_url,count) VALUES('$username','','$timeanddate','$username uploaded a new picture on','http://wiistream.info/users/$username/images/pictures/thumb/$filename','1','http://wiistream.info/users/$username/images/pictures/$filename','0')") or die(mysql_error()); //If there is a match for the username, echo the the users xml data. } else { echo "WiiStream Eorror!"; } ?>
  13. HERE ARE MY SCRIPTS Resize.PHP <?php /* * File: SimpleImage.php * Author: Simon Jarvis * Copyright: 2006 Simon Jarvis * Date: 08/11/06 * Link: http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details: * http://www.gnu.org/licenses/gpl.html * */ class SimpleImage { var $image; var $image_type; function load($filename) { $image_info = getimagesize($filename); $this->image_type = $image_info[2]; if( $this->image_type == IMAGETYPE_JPEG ) { $this->image = imagecreatefromjpeg($filename); } elseif( $this->image_type == IMAGETYPE_GIF ) { $this->image = imagecreatefromgif($filename); } elseif( $this->image_type == IMAGETYPE_PNG ) { $this->image = imagecreatefrompng($filename); } } function save($filename, $image_type=IMAGETYPE_JPEG, $compression=75, $permissions=null) { if( $image_type == IMAGETYPE_JPEG ) { imagejpeg($this->image,$filename,$compression); } elseif( $image_type == IMAGETYPE_GIF ) { imagegif($this->image,$filename); } elseif( $image_type == IMAGETYPE_PNG ) { imagepng($this->image,$filename); } if( $permissions != null) { chmod($filename,$permissions); } } function output($image_type=IMAGETYPE_JPEG) { if( $image_type == IMAGETYPE_JPEG ) { imagejpeg($this->image); } elseif( $image_type == IMAGETYPE_GIF ) { imagegif($this->image); } elseif( $image_type == IMAGETYPE_PNG ) { imagepng($this->image); } } function getWidth() { return imagesx($this->image); } function getHeight() { return imagesy($this->image); } function resizeToHeight($height) { $ratio = $height / $this->getHeight(); $width = $this->getWidth() * $ratio; $this->resize($width,$height); } function resizeToWidth($width) { $ratio = $width / $this->getWidth(); $height = $this->getheight() * $ratio; $this->resize($width,$height); } function scale($scale) { $width = $this->getWidth() * $scale/100; $height = $this->getheight() * $scale/100; $this->resize($width,$height); } function resize($width,$height) { $new_image = imagecreatetruecolor($width, $height); imagecopyresampled($new_image, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight()); $this->image = $new_image; } } ?>
  14. <?php //ob_start(); include "../connect.php"; Header('Cache-Control: no-cache'); Header('Pragma: no-cache'); $UserId=$_POST['UserId']; $UserId = stripslashes($UserId); $UserId = mysql_real_escape_string($UserId); $UserName=$_POST['UserName']; $UserName = stripslashes($UserName); $UserName = mysql_real_escape_string($UserName); $UserFirstName=$_POST['UserFirstName']; $UserFirstName = stripslashes($UserFirstName); $UserFirstName = mysql_real_escape_string($UserFirstName); $UserLastName=$_POST['UserLastName']; $UserLastName = stripslashes($UserLastName); $UserLastName = mysql_real_escape_string($UserLastName); $UserGender=$_POST['UserGender']; $UserGender = stripslashes($UserGender); $UserGender = mysql_real_escape_string($UserGender); $UserLink=$_POST['UserLink']; $UserLink = stripslashes($UserLink); $UserLink = mysql_real_escape_string($UserLink); $UserPicture=$_POST['UserPicture']; $UserPicture = stripslashes($UserPicture); $UserPicture = mysql_real_escape_string($UserPicture); $sql="SELECT * FROM Fb_Profile WHERE UserId='$UserId' and UserName ='$UserName' and UserFirstName ='$UserFirstName' and UserLastName ='$UserLastName' and UserGender ='$UserGender' and UserLink ='$UserLink' and UserPicture ='$UserPicture'"; $result=mysql_query($sql); $count=mysql_num_rows($result); //Lets add a first time active check 0 or 1 if 1 skip and check for update<br /> if($UserId == 'undefined') { return true; } if($count==1) { echo "&msgText=Facebook MySql Copy Successfully!\n"; return false; } else { echo "&msgText=Invalid Login!\n"; //THIS HERE IS WHAT I AM HAVING A PROBLEM WITH, IF STATEMENT STATING THAT IF $UserId IS EMPTY AND THE OTHER VARIABLES RETURN NOTHING BUT IF IS HAS A VALUE IT INSERTS //IF(!empty $UserId) $FB_Profile_Copy = mysql_query("INSERT INTO Fb_Profile(UserId,UserName,FirstName,LastName,Gender,Link,Picture) VALUES('$UserId','$UserName','$UserFirstName','$UserLastName','$UserGender','$UserLink','$UserPicture')"); $FB_BackGround_Copy = mysql_query("INSERT INTO Fb_BackGround(UserId) VALUES('$UserId')"); return false; } ?>
  15. NVM, It was a simple fix All you have to do is define the fields you want in the api $user_profile = $facebook->api('/me?fields=id,name'); And so on get what ever you want and need.. so simple.
  16. You see if i fill out Facebook and add a lot of information it pulls all the information, How can I only pull the information I want, is there a way to remove some of the output? This is full all and i still think the file can load much much more, if you like say 100 teams the xml file would load different again, and it would be so much larger, same for music schools and anything else you have on your facebook Information page. <?xml version="1.0"?> <root><0><id>100001957015772</id><name>Clarity Understanding</name><first_name>Clarity</first_name><last_name>Understanding</last_name><link>http://www.facebook.com/clarity.understanding</link><username>clarity.understanding</username><hometown><id>112890068728512</id><name>Heavenly Hills, California</name></hometown><location><id>112890068728512</id><name>Heavenly Hills, California</name></location><work><0><employer><id>227528230633747</id><name>CEO Clarity Dreams</name></employer><location><id>106274566070183</id><name>Winchester, Kentucky</name></location><position><id>143257402365425</id><name>Web Developer</name></position><description>All that I learned from the first day I got a PC, until now, lets see what I can do.</description><start_date>1995-01</start_date></0></work><sports><0><id>181901631820268</id><name>NASCAR</name></0><1><id>104019549633137</id><name>Football</name></1></sports><favorite_teams><0><id>126315184089478</id><name>Jeff gordan</name></0><1><id>110264072330485</id><name>Colts football</name></1></favorite_teams><favorite_athletes><0><id>109563725729117</id><name>Peyton Manning</name></0></favorite_athletes><inspirational_people><0><id>183034171772476</id><name>My God My Lord My Jesus My Son</name></0></inspirational_people><education><0><school><id>115250758498809</id><name>WCHS</name></school><year><id>131821060195210</id><name>1997</name></year><type>High School</type></0><1><school><id>155092571249950</id><name>The Book Of God Is My Teacher.</name></school><year><id>138792749476094</id><name>1978</name></year><concentration><0><id>193730633989737</id><name>The Word of God</name></0></concentration><type>College</type></1></education><gender>male</gender><email>clarity-understanding@hotmail.com</email><timezone>-4</timezone><locale>en_US</locale><languages><0><id>113301478683221</id><name>American English</name></0><1><id>104073086294557</id><name>Biblical Hebrew</name></1><2><id>112307105452806</id><name>Ancient Greek</name></2></languages><verified>1</verified><updated_time>2011-10-03T00:07:59+0000</updated_time></0></root> Here is my problem, as i log into another Facebook account and I read the xml file again, it is different. <?xml version="1.0"?> <root><0><id>100002678639121</id><name>Rob Puckett</name><first_name>Rob</first_name><last_name>Puckett</last_name><link>http://www.facebook.com/profile.php?id=100002678639121</link><gender>male</gender><email>sarahwickly@yahoo.com</email><timezone>-4</timezone><locale>en_US</locale><verified>1</verified><updated_time>2011-09-27T21:15:24+0000</updated_time></0></root> You see it only gets some of the information I have set on my facebook, so what can I do to make the array only get the ID, FIRST NAME LAST NAME EMAIL GENDER AND ANY OTHER I WANT? But at my own request? Would any one know?
  17. My question is can you write a php file that loads a http://URL from off site, then Write the off site array to a xml file on your own domain? Example facebooks https://graph.facebook.com/btaylor loads the users basic Information into a array. { "id": "220439", "name": "Bret Taylor", "first_name": "Bret", "last_name": "Taylor", "link": "http://www.facebook.com/btaylor", "username": "btaylor", "gender": "male", "locale": "en_US" } So can php pull that http://URL and see that its a array, then convert it to a xml file // Get User ID $user = $facebook->getUser(); // We may or may not have this data based on whether the user is logged in. // // If we have a $user id here, it means we know the user is logged into // Facebook, but we don't know if the access token is valid. An access // token is invalid if the user logged out of Facebook. if ($user) { try { // Proceed knowing you have a logged in user who's authenticated. $user_profile = $facebook->api('/me'); } catch (FacebookApiException $e) { error_log($e); $user = null; } } // Login or logout url will be needed depending on current user state. if ($user) { $logoutUrl = $facebook->getLogoutUrl(); } else { $loginUrl = $facebook->getLoginUrl(); } $profile = array ($user_profile); $xml = new SimpleXMLElement('<root/>'); arrayToXML( $xml, $profile ); echo $xml->asXML(); function arrayToXML( SimpleXMLElement &$xml, $array ) { foreach( $array as $name => $value ) { if( !is_array($value) ) $xml->addChild( $name, $value ); else { $child = $xml->addChild( $name ); arrayToXML( $child, $value ); } } } ?> But when i use this and convert it over to xml, the XML file changes The array has so much more in it, then I need all I want is the basics. Like the link above.
  18. Ya I cant get it working like this. I only have this one var to work with $user_profile and if i <pre><?php print_r $user_profile ?> </pre> I can see the array layout. if ($user) { try { // Proceed knowing you have a logged in user who's authenticated. $user_profile = $facebook->api('/me'); } catch (FacebookApiException $e) { error_log($e); $user = null; } } // Login or logout url will be needed depending on current user state. if ($user) { $logoutUrl = $facebook->getLogoutUrl(); } else { $loginUrl = $facebook->getLoginUrl(); } $profile = array ($user_profile); <----------------------Get a error here! $xml = new SimpleXMLElement('<root/>'); arrayToXML( $xml, $profile ); echo $xml->asXML(); function arrayToXML( SimpleXMLElement &$xml, $array ) { foreach( $array as $name => $value ) { if( !is_array($value) ) $xml->addChild( $name, $value ); else { $child = $xml->addChild( $name ); arrayToXML( $child, $value ); } } }
  19. <pre> Array ( [id] => 100000215611178 [name] => Rob Puckett [first_name] => Rob [last_name] => Puckett [link] => http://www.facebook.com/profile.php?id=100000215611178 [education] => Array ( [0] => Array ( [school] => Array ( [id] => 115250758498809 [name] => WCHS ) [year] => Array ( [id] => 139539632730771 [name] => 1972 ) [type] => High School ) ) [gender] => male [timezone] => -4 [locale] => en_US [verified] => 1 [updated_time] => 2011-07-28T11:02:34+0000 ) </pre>
  20. This is a Facebook var that give the basic information of the user. like userID the picture names and crap. I'm wanting to take the array and brake it apart so i can use xml with it. $test_array = array ($user_profile); $xml = new SimpleXMLElement('<root/>'); array_walk_recursive($test_array, array ($xml, 'addChild')); print $xml->asXML(); the $user_profile var gives all the information. but when it echos out of the php it echos backwards. I need to flip it somehow any ideas. This is what i mean when I say backwards. <?xml version="1.0"?> <root> <100000215611178>id</100000215611178> <Rob Puckett>name</Rob Puckett> <Rob>first_name</Rob> <Puckett>last_name</Puckett> <//www.facebook.com/profile.php?id=100000215611178>link<///www.facebook.com/profile.php?id=100000215611178> <115250758498809>id</115250758498809> <WCHS>name</WCHS> <139539632730771>id</139539632730771> <1972>name</1972> <High School>type</High School> <male>gender</male> <-4>timezone</-4> <en_US>locale</en_US> <1>verified</1> <02:34+0000>updated_time</02:34+0000> </root> you see how it is backwards? how can I flip it so its like this. <?xml version="1.0"?> <root> <id>100000215611178</id> <name>Rob Puckett</name> <first_name>Rob</first_name> <last_name>Puckett</last_name></root>
  21. So that would be in my sql result.. so somthing like this? $sql = "SELECT a.username,a.comment,a.timestamp,a.title,a.picture,a.pic_status,a.pic_url,b.id,c.avatar,c.atimestamp,c.onlinestatus FROM (user_comments as a JOIN accounts as c USING(username))JOIN `user_friends_list` as b ON (b.friend = a.username)WHERE (b.username = '$username' $friend AND b.status = 1) ORDER BY a.id DESC LIMIT 0, 25";
  22. I have this code and Im using a while to fetch all the data where users comments are but i want to change it to fetch only 25 rows at a time and each time it refreshes it fetch's 25 more different rows. <?php include "../../connect.php"; Header('Cache-Control: no-cache'); Header('Pragma: no-cache'); $username = mysql_real_escape_string($_GET['username']); //If friend is set, then query for it, otherwise return all of the friends comments. $friend = (isset($_GET['friend'])) ? ' AND b.friend = \'' . mysql_real_escape_string($_GET['friend']) . '\' ' : NULL; $sql = "SELECT a.username,a.comment,a.timestamp,a.title,a.picture,a.pic_status,a.pic_url,b.id,c.avatar,c.atimestamp,c.onlinestatus FROM (user_comments as a JOIN accounts as c USING(username))JOIN `user_friends_list` as b ON (b.friend = a.username)WHERE (b.username = '$username' $friend AND b.status = 1) ORDER BY a.id DESC"; $result = mysql_query($sql); $user_xml = "<?xml version=\"1.0\"?>\n"; //$user_xml .= "<root>\n"; if(mysql_num_rows($result) > 0) { while ($row = mysql_fetch_assoc($result)) { $user_xml .= "<comment>\n"; $user_xml .= "<image>" . $row['avatar'] . "</image>\n"; $user_xml .= "<name>" . $row['username'] . "</name>\n"; $user_xml .= "<text>\n"; $user_xml .= "<![CDATA[ ". $row['comment'] ."]]>\n"; $user_xml .= "</text>\n"; $user_xml .= "<time>" . $row['timestamp'] . "</time>\n"; $user_xml .= "<title>" . $row['title'] . "</title>\n"; $user_xml .= "<picture>" . $row['picture'] . "</picture>\n"; $user_xml .= "<status>" . $row['pic_status'] . "</status>\n"; $user_xml .= "<url>" . $row['pic_url'] . "</url>\n"; $user_xml .= "<ntimestamp>" . $row['atimestamp'] . "</ntimestamp>\n"; $user_xml .= "<online>" . $row['onlinestatus'] . "</online>\n"; $user_xml .= "</comment>\n"; } } //$user_xml .= "</root>\n"; echo $user_xml; ?> So i think i can do something like this but im not to sure. just add a if statement while ($row = mysql_fetch_assoc($result)) { $user_xml .= "<comment>\n"; $user_xml .= "<image>" . $row['avatar'] . "</image>\n"; $user_xml .= "<name>" . $row['username'] . "</name>\n"; $user_xml .= "<text>\n"; $user_xml .= "<![CDATA[ ". $row['comment'] ."]]>\n"; $user_xml .= "</text>\n"; $user_xml .= "<time>" . $row['timestamp'] . "</time>\n"; $user_xml .= "<title>" . $row['title'] . "</title>\n"; $user_xml .= "<picture>" . $row['picture'] . "</picture>\n"; $user_xml .= "<status>" . $row['pic_status'] . "</status>\n"; $user_xml .= "<url>" . $row['pic_url'] . "</url>\n"; $user_xml .= "<ntimestamp>" . $row['atimestamp'] . "</ntimestamp>\n"; $user_xml .= "<online>" . $row['onlinestatus'] . "</online>\n"; $user_xml .= "</comment>\n"; } I only wnat to read 25 comments at a time and when i click a button to read more then it reads 25 more rows but it dose not read the data unless requested... can any one help me?
  23. Do any of you know how to override the php.ini file on a webhost to allow uploads using php to be set for 2gig mx file size? .htaccess is not working and my host says it supports changing the php.ini but nothing seems to be working.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.