2

I'm trying to combine Drupal with Picasa web integrator.

I have these 3 lines in the section of my page.tpl.php:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="/fotos/js/jquery.slimbox2/jquery.slimbox2.js" language="JavaScript"></script>
<script type="text/javascript" src="/fotos/js/jquery.pwi.js" language="JavaScript"></script>

I also added this script to my head section, to test an album (the username and albumname are not important, I tested it offline with my username and album and that worked fine):

<script type="text/javascript">

$(document).ready(function() {

    $("#container").pwi({
        username: 'My',
        maxresults: 5,
        mode: 'album',
        album: 'MyAlbum'
    });

});
</script>

Google Chrome gives me this error when I try it on my Drupal-page:

prototype.js:5733Uncaught TypeError: Object#<Object> has no method 'dispatchEvent'

having problems passing array values

I'm building a PHP program that basically grabs only image links from my twitter feed and displays them on a page, I have 3 components that I have set up that all work fine on their own.

The first component is the twitter oauth component which grabs the tweet text and creates an array, this works fine by itself.

The second is a function that processes the tweets and only returns tweets that contain image links, this as well works fine.

The program breaks down during the third section when the links are processed and an image is displayed, I had no issues running this on its own and from my attempts to trouble shoot it appears that it breaks down at the $images(); array, as that array is empty.

I'm sure I've made a silly mistake but I've been trying to find this for over a day now and can't seem to fix it. Any help would be great! Thanks guys!

code:

<?php

if ($result['socialorigin']== "twitter"){
$twitterObj = new EpiTwitter($consumer_key, $consumer_secret);
$token = $twitterObj->getAccessToken();
$twitterObj->setToken($result['oauthtoken'], $result['oauthsecret']);
$tweets = $twitterObj->get('/statuses/home_timeline.json',array('count'=>'200'));

         $all_tweets = array();
         $hosts  = "lockerz|yfrog|twitpic|tumblr|mypict|ow.ly|instagr";



         foreach($tweets as $tweet) {

         $twtext = $tweet->text;

         if(preg_match("~http://($hosts)~", $twtext)){

         preg_match_all("#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t<]*)#ise", $twtext, $matches, PREG_PATTERN_ORDER);

         foreach($matches[0] as $key2 => $link){

         array_push($all_tweets,"$link");

         }

         }

         }
function height_compare($a1, $b1)
{
    if ($a1 == $b1) {
        return 0;
    }
    return ($a1 > $b1) ? -1 : 1;
}

foreach($all_tweets as $alltweet => $tlink){
$doc = new DOMDocument();
// Okay this is HTML is kind of screwy
// So we're going to supress errors
@$doc->loadHTMLFile($tlink);

// Get all images
$images_list = $doc->getElementsByTagName('img');

$images = array();
foreach($images_list as $image) {

  // Get the src attribute
  $image_source = $image->getAttribute('src');

  if (substr($image_source,0,7)=="http://"){
  $image_size_info = getimagesize($image_source);

  $images[$image_source] = $image_size_info[1];
  }
}



// Do a numeric sort on the height
uasort($images, "height_compare");
$tallest_image = array_slice($images, 0,1);
$mainimg = key($tallest_image);

echo "<img src='$mainimg' />";


 }
 print_r($all_tweets);
 print_r($images);

}
4

2 回答 2

3

Drupal 还附带 jQuery,您不能简单地在<script>标签中添加更高版本。您可以尝试使用Drupal 的 jquery 更新来获取更新的版本,或者尝试noConflict(我怀疑如果您想使用 Prototype,无论如何您都需要它)。

于 2011-06-13T14:06:40.510 回答
3

看起来您也在页面上加载了prototype.jslightbox.js也许是?,并且$jQuery和Prototype使用的可能是冲突的。如果您确实需要同时使用Prototype和jQuery,请考虑使用jQuery的noConflict模式:http://api.jquery.com/jQuery.noConflict/

于 2011-06-13T14:04:28.253 回答