[Developers] coldfusion
Ryan Miller
ninjascience at gmail.com
Tue Aug 7 03:48:14 UTC 2007
Mark,
I was playing with the MQL Write services this afternoon and saw their
example of using the login API, what you were tryin to do with the
first http post in your code. After messing around I figured out that
the username needs to be your email address. I also used a chttp
param to specify the content type. The returned content is a JSON
string but CF turns it into a Java ByteArrayOutputStream. Just use
it's toString() method to see if the login succeeds (metaweb always
returns a 200 status, even if the login fails, you need to inspect the
JSON string to know if it succeeded.
<cfhttp URL="http://www.freebase.com/api/account/login" method="POST">
<cfhttpparam name="Content-Type"
value="application/x-www-form-urlencoded" type="header" />
<cfhttpparam name="username" value="myaddy at gmail.com" type="formfield" />
<cfhttpparam name="password" value="mypassword" type="formfield" />
</cfhttp>
<cfdump var="#cfhttp.filecontent.toString()#" />
On 8/6/07, Ryan Miller <ninjascience at gmail.com> wrote:
> from what I can tell you're trying to do an HTTP POST to the freebase
> site with your username and password sent as POST variables, getting
> the metaweb-user cookie out of that response, than using that to do
> your mql POST. Why not just lookup your metaweb-user cookie value out
> of your browser and hard-code into your app? When I tried your code
> the first POST that should return the cookie doesn't, so if you want
> to keep going this route, concentrate there. Make sure your sending
> the vars under the right names (including case), and fake the
> user-agent string to a common browser.
>
> On 8/6/07, Mark CE <markce at btclick.com> wrote:
> >
> >
> > Don't worry I have tried both POST and GET, many times now!
> >
> > Two crappy CF templates attached (testme.cfm which calls testme2.cfm). I
> > am not familiar with this list; if it doesn't accept attachments and I
> > should be including the code in the body of this email, I guess I'll find
> > out when my message comes back.
> >
> > Needless to say, the cookie-getting function does work and successfully
> > returns the two cookies:
> > metaweb-user and metaweb-user-info.
> >
> > -----------------------
> > Originally I wasn't deserialising the JSON response so hence the unhelpful
> > error message.
> > Now the response is:
> >
> > code: /api/status/error/input/invalid
> > message: authentication required
> > ----------------------
> >
> > Thanks again
> > Mark
> >
> >
> >
> > At 16:34 06/08/2007, you wrote:
> >
> >
> > In addition to the cookie requirement, you probably need to do your
> > cfhttp call as a POST, cfhttp is a GET by default. If that doesn't
> > work post your cfhttp code here to the list.
> >
> > On 8/6/07, Mark CE <markce at btclick.com> wrote:
> > >
> > >
> > > Hello there,
> > > Has anyone successfully retrieved a query result from Freebase using
> > > Coldfusion CFHTTP?
> > > Or know of a reason why mine would return a 400 error?
> > >
> > > HTTP/1.0 400 Bad Request X-Metaweb-Cost: dt=0.001, nreqs=0 Date: Fri, 03
> > > Aug 2007 16:10:49 GMT X-Metaweb-TID:
> > > cache;cache01.p01.sfo1:8101;2007-08-03T16:10:49Z;0002
> > > Server: Apache/2.0.58 Vary: Accept-Encoding Cache-Control: no-cache
> > > Content-Type: applic
> > >
> > > If instead of CFHTTP I get my coldfusion code to output the URL to the
> > > page; I copy and paste into the address bar, I get a 200 response... and
> > the
> > > query results I would expect.
> > >
> > > Working code samples gratefully received!!!
> > > Thanks
> > > Mark CE
> > >
> > >
> > >
> > > ________________________________
> > > Mark Christian-Edwards
> > > markce at btclick.com
> > >
> > >
> > >
> > >
> > > _______________________________________________
> > > Developers mailing list
> > > Developers at freebase.com
> > > http://lists.freebase.com/mailman/listinfo/developers
> > >
> > >
> >
> >
> >
> > --
> > No virus found in this incoming message.
> > Checked by AVG Free Edition.
> > Version: 7.5.476 / Virus Database: 269.11.6/938 - Release Date: 05/08/2007
> > 16:16
> >
> >
> > No virus found in this outgoing message.
> > Checked by AVG Free Edition.
> > Version: 7.5.476 / Virus Database: 269.11.6/938 - Release Date: 05/08/2007
> > 16:16
> >
> >
> >
>
More information about the Developers
mailing list