Issue 1: You don't want to encode the ampersands in line 12... they're valid
(and required) characters in URIs.  Switch those back to just & and you
should get 200 responses.

Issue 2:  it looks like you want trends, however you're calling the search
results URL.  This will return a JSON object that contains an array of
results, not trends.  So it's likely that once you fix the first ampersand
issue you'll just be running through an empty list in your echo.

Issue 3: on lines 18 and 19 you will probably run into issues with XML
encoding.  These echo statements must emit valid XML, or the consumer won't
be able to parse the returned document.  This usually means calling some
function on the string that converts reserved XML characters (<, >, ', ",
and &) to their escaped forms.  I'm not at all familiar with PHP, but I'd
suggest using an actual XML builder to construct the XML.  If you want to
test, you can always call this URL directly and see if
firefox/IE/safari/whatever think your emitted XML is valid.

   ---Mark

On Sun, Oct 25, 2009 at 10:20 AM, TrixJo <tri...@gmail.com> wrote:

>
> I have used the ampersand which is displayed in my code here:
>
> http://pastebin.com/m51f7a9dd
>
> are there any other takers who can give me advice on why I get the
> errors:
>
> failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden
>
>
>
>
>
> On Oct 24, 1:23 pm, Mark Mcbride <mmcbr...@twitter.com> wrote:
> > If you're embedding that URL in XML you will need to XML encode it...
> > In this specific case the ampersand (&q=...) needs to be replaced with
> > &amp;
> >
> > Sent from mobile device
> >
> > On Oct 24, 2009, at 10:19 AM, JDG <ghil...@gmail.com> wrote:
> >
> >
> >
> > > You sure that's where the error is? there have been numerous
> > > reported problems with PHP's JSON decoder that it doesn't handle the
> > > very large numbers of Twitter's IDs well.
> >
> > > On Sat, Oct 24, 2009 at 11:11, TrixJo <tri...@gmail.com> wrote:
> >
> > > Hello
> >
> > > I am trying to search twitter content using a mySQL/PHP entry in a
> > > table:
> >
> > > $contents = file_get_contents(
> > >                    "http://search.twitter.com/search.json?
> > > lang=en&rpp=5&q=".urlencode($row[topicTitle]));
> >
> > > $json = json_decode($contents);
> >
> > > I am returning the results via AJAX as an XML file
> >
> > > The problem that I get is:
> >
> > > XML Parsing Error: not well-formed
> > > Location:http://www.domain.com/path/to/my/script.php?&id=2765
> > > Line Number 77, Column 44:    [refresh_url] => ?
> > > since_id=5126537872&q=Indonesia
> >
> > > where "Indonesia" happens to be the value of $row[topicTitle]
> >
> > > The problem is with the value of $row[topicTitle]  -- doesn't matter
> > > if the term is "Indonesia" or any other word or phrase (I tried a
> > > bunch) -- I keep getting that XML error
> >
> > > I also tried enclosing it with single quotes, same error
> >
> > > help please?
> >
> > > --
> > > Internets. Serious business.
>

Reply via email to