asked on
facebook-parser.php
<?php
$page_id = 'cnninternational';
$newsfeed = "";
if (isset($_GET['page_id']))
{
$page_id = $_GET['page_id'] ;
}
$access_token = 'xxxxxxxxxxxxx';
//Get the JSON
$json_object = file_get_contents('https://graph.facebook.com/'.$page_id.'/posts?access_token='.$access_token);
//Interpret data
$fbdata = json_decode($json_object);
$posts="";
$BTseparator = "\n"."BT"."\n"."http://";
$normalseparator = "\n"."http://";
$i = 0;
$newsfeed = $newsfeed."<table>";
foreach($fbdata->data as $item){
if (isset($item->message))
{
$color = "#B2E0F0" ;
if ($i % 2 == 0)
{
$color = "#B2E0F0";
} else {
$color = "#E8F6FA";
}
$newsfeed = $newsfeed. '<tr bgcolor="'.$color .'"><td>';
if (strpos($item->message, $BTseparator ) !== false){
$text = explode ($BTseparator, $item->message);
$newsfeed = $newsfeed. $text[0] . '<br>';
} else {
if (strpos($item->message, $normalseparator ) !== false) {
$text = explode ($normalseparator, $item->message);
$newsfeed = $newsfeed.$text[0] . '<br />';
} else {
$newsfeed = $newsfeed. $item->message . '<br />';
}
}
}
if (isset($item->picture)){
$newsfeed = $newsfeed. '<a href="' . $item->picture . '"><img style="border:0;" src="' . $item->picture . '"></a><br />';
}
if ((isset($item->link)) && (strpos($item->link , "youtube") !== false)) {
$newsfeed = $newsfeed.'<a href="' . $item->link . '">Watch Video</a><br />';
}
$newsfeed = $newsfeed. '<b>' . $item->from->name . '</b><br />';
$newsfeed = $newsfeed. 'Timestamp: ' . $item->created_time . '<br /></td></tr>';
$i = $i + 1;
}
$newsfeed = $newsfeed. '</table>';
$newsfeed = $newsfeed. '<table>';
$newsfeed = $newsfeed. '<tr><td>';
$newsfeed = $newsfeed. '<a href="facebook-example.php?page_id=cnninternational">cnninternational</a>';
$newsfeed = $newsfeed. ' </td>';
$newsfeed = $newsfeed. ' <td>';
$newsfeed = $newsfeed. ' <a href="facebook-example.php?page_id=bbcnews">bbc news</a>';
$newsfeed = $newsfeed. '</td></tr>';
$newsfeed = $newsfeed. '</table>';
echo $newsfeed;
?>
<style>
.ui-widget-content {
margin-top: 90px;
background-position: top left;
width: 150px;
height: 150px;
padding: 0.5em;
position: absolute;
overflow: auto;
}
.ui-resizable-helper { border: 2px dotted #00F; }
.ui-draggable, .ui-droppable {
background-position: top;
}
#window1 h3 {
text-align: left;
margin: 0;
font-family:"lucida grande",tahoma,verdana,arial,sans-serif;
font-size: 14px;
color: #FFF;
background: #3B5998;
}
#window2 h3 {
text-align: left;
margin: 0;
font-family:"helvetica neu",arial,helvetica;
font-size: 14px;
color: #FFF;
background: #7D26CD;
}
#window3 h3 {
text-align: left;
margin: 0;
font-family:arial,helvetica;
font-size: 14px;
color: #FFF;
background: #CC0000;
}
#window4 h3 {
text-align: left;
margin: 0;
font-family:"Arial Black", Gadget, sans-serif;
font-size: 14px;
color: #FFF;
background: #1F2E2E;
}
</style>
<script type='text/javascript'>
$(function() {
var start = function() {
$(this).insertAfter(".ui-widget-content:last");
}
$( ".ui-widget-content" )
.draggable({containment: "#main"},{ cursor: "move", cursorAt: { top: 56, left: 56 }, start:start })
.resizable({animate: true},{helper: "ui-resizable-helper"});
/*jQuery("#window3").tubeplayer({ jQuery.tubeplayer.min.js });*/
$.get("facebook-parser.php", {}, function(response){
$("#window1").html(response);
});
$('#window2').weatherfeed(['734353'],{
woeid: true,
unit: 'c',
image: true,
country: true,
highlow: true,
wind: true,
humidity: true,
visibility: true,
sunrise: true,
sunset: true,
forecast: true,
link: true
});
});
</script>
<div id="window1" class="ui-widget-content">
<h3 class="ui-widget-header"> Facebook</h3>
<p id="window1content">Window's content is not set</p>
</div>
<div id="window2" class="ui-widget-content">
<h3 class="ui-widget-header"> Weather</h3>
</div>
</div>
<div id="window3" class="ui-widget-content">
<h3 class="ui-widget-header"> YouTube</h3>
</div>
<div id="window4" class="ui-widget-content">
<h3 class="ui-widget-header"> News</h3>
</div>
The Ajax function here is displaying the initial content in the div, but when I click the link inside it, it displays the result in main screen, also for some reason after adding this ajax I lost the resizable property, I cannot expand the div.
ASKER
ASKER
$("a", "#window1").click(function(evt) {
var href = $(this).attr("href");
by : $("a", "#window1").click(function(evt) {
evt.preventDefault();
var href = $(this).attr("href");
ASKER
what do you advise?
ASKER
$.get("facebook-parser.php", {}, function(response){
$("#window1container").html(response);
$("a", "#window1").click(function(evt){
evt.preventDefault();
var href = $(this).attr("href");
if( href && (href.indexOf("#")!=0) && (href.indexOf("javascript:")!=0) ) {
$("#window1").load("get_content.php?url=" + encodeURIComponent(href));
}
});
});
$.get("facebook-parser.php", {}, function(response){
$("#window1container").html(response);
$("a", "#window1container").click(function(evt){
evt.preventDefault();
if ($(this).hasClass("pageLink")) {
var href = $(this).attr("href");
if( href && (href.indexOf("#")!=0) && (href.indexOf("javascript:")!=0) ) {
$("#window1container").load("facebook-parser.php?page_id=" + encodeURIComponent(href));
}
}
});
});
$newsfeed = $newsfeed. '<a href="facebook-parser.php?page_id=cnninternational" >cnninternational</a>';
$newsfeed = $newsfeed. ' </td>';
$newsfeed = $newsfeed. ' <td>';
$newsfeed = $newsfeed. ' <a href="facebook-parser.php?page_id=bbcnews" >bbc news</a>';
$newsfeed = $newsfeed. '<a href="cnninternational" class="pageLink" >cnninternational</a>';
$newsfeed = $newsfeed. ' </td>';
$newsfeed = $newsfeed. ' <td>';
$newsfeed = $newsfeed. ' <a href="bbcnews" class="pageLink">bbc news</a>';
ASKER
ASKER
PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.
TRUSTED BY
Open in new window
by :Open in new window
you've a script on your server to download the new page, get_content.php :
Open in new window
If that work well for you, you're lucky else maybe you should consider it's an impossible mission.
for your resizable property you're overwritting content of the div where you have the resizable icon with the .html(response)
you should use an other div inside each window
so replacing :
Open in new window
by :Open in new window
and use :
Open in new window