WPG2 working great, but how can I get Facebook to show [wpg2] tagged images?

wsitch

Joined: 2009-01-22
Posts: 6
Posted: Thu, 2009-01-22 19:11

Hi everyone,

This is the holy grail for me: storing my own photos locally (done), managing my photos with picasa3 (done), moving selected albums from my local computer to my own server with picasa3 and gallery2 (done), hosting my own blog on my own server with wordpress (done), hosting my own photos on my own server with gallery2 (done), using photos on my own server in my blog with wpg2 (done), exporting blog posts from my server to facebook (kinda done), showing photos from my server in my facebook replicated blog posts (not done).

The problem is the last step. Like most people, my friends are all on facebook. I want my blog posts to be mirrored onto facebook so my friends can see what I'm writing without clicking through to my blog. Currently I have facebook import "wall notes" from my blog RSS feed, but of course the WPG2 tags aren't being recognized or expanded into photos.

So I make a blog post that looks like: "Hello world! <wpg2>2185</wpg2>", which looks like "Hello world! [picture]" on my blog, and "Hello world! 2185" on facebook.

How can I get facebook to understand the WPG2 tags? Is there a better way to do this?

Thanks!

Will

 
ozgreg
ozgreg's picture

Joined: 2003-10-18
Posts: 1378
Posted: Thu, 2009-01-22 21:13

I have had a play around with this concept a few times.. Using RSS feed you get WPG2 Images and the blog posts perfectly however RSS Posts do not show up on your friend's activity list. Using the Wordbook Facebook/Wordpress Plugin gets you closer but it seems to be using a summary feed so you only get some of your post, with no images but it does show up on your friends activity lists.

I had a very quick poke around with the wordbook plugin and looks like it was developed using some older facebook api calls which is why I am guessing the images are not pulled over as WPG2 tags should automatically be processed!

I not really had much of a chance to look more into this, the Facebook API documentation is not that clear..

____________________________________
Wordpress / Gallery2 (WPG2) Plugin, , WPG2 Documentation, WPG2 Demo

 
kckong

Joined: 2007-07-06
Posts: 21
Posted: Tue, 2009-03-03 14:31

I have the same problem as wsitch & it's driving me nuts. The text in my blog posts show up on my facebook wall but without the wpg2 tagged images.

When i look at the access logs, I can see that facebook tried accessing those photos but are denied - ie code 500 security violation I think.

I had enabled hotlink protection before & I thought that was the problem. But even with hotlink protection disabled, facebook is still getting code 500s when it tries to import those images.

Help please :)

ps: here's an extract from my access log

/gallery/main.php?g2_view=core.DownloadItem&amp%3Bg2_itemId=123456&amp%3Bg2_GALLERYSID=TMP_SESSION_ID_D
Http Code: 500 Date: Mar 03 22:10:09 Http Version: HTTP/1.1 Size in Bytes: 769
Referer: -
Agent: facebookexternalhit/1.0 (+http://www.facebook.com/externalhit_uatext.php)

 
geddeth
geddeth's picture

Joined: 2004-05-16
Posts: 52
Posted: Sun, 2009-03-08 22:38

kckong:
That's pretty weird - why is your webserver generating HTTP 500's? Or is that in fact Gallery doing the generating?

In any case, HTTP 500 is not a security violation, it's an internal server error. So it may be something entirely different.
Can you access the URL's in your logs yourself manually?

 
kckong

Joined: 2007-07-06
Posts: 21
Posted: Mon, 2009-03-09 09:08

Geddeth, I don't know much about the ins and outs butIt's weird to me :(

When I click those links from the access log (example posted earlier), I get this message:

Quote:
"Security Violation
The action you attempted is not permitted.

Back to the Gallery "

But when I click "view original post" from my facebook, I can see the images correctly.

You're probably right that it's gallery that's generating the 500's BUT I think it's the code that WPG2 generates when I put in the WPG2 tag (to embed the image from gallery) in the blog posting that's objectionable

any ideas?

 
wsitch

Joined: 2009-01-22
Posts: 6
Posted: Fri, 2009-03-20 04:15

I'm still struggling with this. I found the access.log and error.log, but no mention of facebook crawling when I post a new wordpress blog posting. Wordbook is working great, just no WPG2 images.

Does anyone have any ideas? Can we ping the developers?

 
wsitch

Joined: 2009-01-22
Posts: 6
Posted: Sun, 2009-04-19 03:58

Okay, I'm going crazy over this.

The src of the images isn't causing the problem. I've used urlrewrite'd src and un-urlrewrite'd src. Neither work. But when I take the HTML code from a previous post and make a new post with that code, it works fine!

So I think the WPG2 tag is causing the problem. The wordbook code is searching through the post contents looking for src="...", but of course the link is stored as [wpg]1242[/wpg]! There's nothing for wordbook to find.

How can I work around this? Ozgreg, can you help? Got any ideas? Is there a way to insert the real link vs. the WPG2 tag? Would that be a bad solution?

Will

 
wsitch

Joined: 2009-01-22
Posts: 6
Posted: Sun, 2009-04-19 04:03
wsitch wrote:
How can I work around this?

Ok, I know how to get around it.

In the wordbook code that parses the post contents for img src="...", we need to add a section that also parses for WPG2 tags!

So the relevant wordbook code is in wordbook.php on lines 1102-1123:

$post_content = $post->post_content;
preg_match_all('/<img \s+ [^>]* src \s* = \s* "(.*?)"/ix',
$post_content, $matches);
$images = array();
foreach ($matches[1] as $ii => $imgsrc) {
if ($imgsrc) {
if (stristr(substr($imgsrc, 0, 8), '://') ===
false) {
/* Fully-qualify src URL if necessary. */
$scheme = $_SERVER['HTTPS'] ? 'https' : 'http';
$new_imgsrc = "$scheme://"
. $_SERVER['SERVER_NAME'];
if ($imgsrc[0] == '/') {
$new_imgsrc .= $imgsrc;
}
$imgsrc = $new_imgsrc;
}
$images[] = array(
'src' => $imgsrc,
'href' => $post_link,
);
}
}

We just need to insert something that'll search for [wpg2] tags and decode them! Ozgreg, can you help with this?

Will

 
wsitch

Joined: 2009-01-22
Posts: 6
Posted: Sat, 2009-07-11 18:41

Hi everyone,

My friend Brad, who knows next to nothing about anything, asked a stupid question and prompted me to figure out how to do this.

Open wordpress.php, find:
function wordbook_fbclient_publishaction

After:
...
$images[] = array(
'src' => $imgsrc,
'href' => $post_link,
);
}
}

Add:
preg_match_all('/<wpg2>(.*?)</ix', $post_content, $wpg_matches);
$wpg_images = array();
foreach ($wpg_matches[1] as $ii => $wpgtag) {
if ($wpgtag) {
$images[] = array(
'src' => "http:// YOUR WPG URL HERE ?g2_view=core.DownloadItem&g2_itemId=" . $wpgtag,
'href' => $post_link,
);
}
}

Before:
$template_data = array(
'images' => $images,
...

To find "YOUR WPG URL HERE", click "Properties" on an image from your blog, figure out your WPG2 display URL, and hack it in.

Good luck.

Will