When you construct your url, you do so with "http://ajax.googleapis.com/ajax/services/feed/load?q= ".$bookmarks[$i]->link_rss."&v=1.0"; . If your rss link has any question marks ( ? ) or ampersands ( & ), then, you can end up with a url that looks something like this:
http://ajax.googleapis.com/ajax/services/feed/load?q=http://mysite.com/my ?cool=feed&url=rocks&v=1.0 This is problematic because the server will see the question mark and may not know where to start parsing the query string correctly. The bigger problem, though, is that the ampersand divides parameter name/ value pairs. So with this url, even if the question mark comes through okay, Google's server is going to see a request with three parameters: q, url, and v. It then simply drops the url parameter, and tries to get the feed at http://mysite.com/my?cool=feed, which may or may not actually be a valid feed. The solution to this is PHP's urlencode function. Simply run $bookmarks[$i]->link_rss through that, and the actual feed url will be encoded so that any non-alphanumeric characters, including question marks, ampersands, and equal signs ( = ), will be hex encoded so as to not mess with the server's query parsing. Once that's done, if the feed still isn't loading, I would output the url that your script is generating at this same line and test it in a browser to see if it's actually working. Jeremy R. Geerdes Effective website design & development Des Moines, IA For more information or a project quote: http://jgeerdes.home.mchsi.com http://jgeerdes.blogspot.com [email protected] Unless otherwise noted, any price quotes contained within this communication are given in US dollars. If you're in the Des Moines, IA, area, check out Debra Heights Wesleyan Church! And check out my blog, Adventures in Web Development, at http://jgeerdes.home.mchsi.com ! On Dec 12, 2008, at 4:10 AM, [email protected] wrote: > > Hi Jeremy, > > I don't think I'm getting any results at all, no, though I'm finding > php a real pig to debug. > I'm sorry, I don't understand what you mean by "encoding the feed > url"?? > JSON is present in my PHP installation. > > Pete > > On Dec 11, 12:36 pm, Jeremy Geerdes <[email protected]> wrote: >> So, are you getting any results at all? If not, the problem could be >> in the fact that you're apparently not encoding the feed url that you >> want (essential if it includes question marks ( ? ) or ampersands >> ( & )). If you are, then check to see if the JSON module is also >> compiled into your PHP installation. >> >> Jeremy R. Geerdes >> Effective website design & development >> Des Moines, IA >> >> For more information or a project quote:http://jgeerdes.home.mchsi.comhttp >> ://jgeerdes.blogspot.com >> [email protected] >> >> Unless otherwise noted, any price quotes contained within this >> communication are given in US dollars. >> >> If you're in the Des Moines, IA, area, check out Debra Heights >> Wesleyan Church! >> >> And check out my blog, Adventures in Web Development, >> athttp://jgeerdes.home.mchsi.com >> ! >> >> On Dec 10, 2008, at 5:35 PM, [email protected] wrote: >> >> >> >>> Hi, >> >>> I'm trying to access the Google Feeds API server side with php. >>> This >>> is to create a wordpress plugin with a bloglist like Blogger has, in >>> pure php. Without doing it server side, the posts can't be listed >>> in >>> order of last updated. To do this I'm messing with someone else's >>> code (with his permission) >> >>> I'm testing in on my website here. The php is evident on the right >>> under the title "In an abundance of counselors" >>> http://www.metepyers.com/ >> >>> But to get more specific: >> >>> if ($bookmarks[$i]->link_rss != '') { >>> $url = "http://ajax.googleapis.com/ajax/services/feed/load?q=". >>> $bookmarks[$i]->link_rss."&v=1.0"; >> >>> $ch = curl_init(); >>> curl_setopt($ch, CURLOPT_URL, $url); >>> curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); >>> curl_setopt($ch, CURLOPT_REFERER, $myhomepage); >>> $body = curl_exec($ch); >>> curl_close($ch); >> >>> $json = json_decode($body, true); >>> $times[$i] = strtotime($json['feed']['entries']['0'] >>> ['publishedDate']); >>> $titles[$i] = $json['feed']['entries']['0']['title']; >>> $links[$i] = $json['feed']['entries']['0']['link']; >>> } >> >>> I'm expecting the $titles variable to contain the texts of the >>> latest >>> post titles... but it's empty. Simply cannot figure out why. >> >>> Any help? > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google AJAX APIs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-AJAX-Search-API?hl=en -~----------~----~----~----~------~----~------~--~---
