Is it possible to add comments to a blog post via HTTP POST methods?
i.e. using a certain URL like
http://www.myblog.com/index.php?url=arc ... -this-post
Anything like this?
Add comments via HTTP POST
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Add comments via HTTP POST
Hi!
Sure, comments are already added via HTTP POST method.
Regards,
Garvin
Sure, comments are already added via HTTP POST method.
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Re: Add comments via HTTP POST
Sounds good. Could you tell me how this is done or where I can find a documentation or example for that. The reason is that I'd like to implement posting comments in my iOS-app which is based on s9y.
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Add comments via HTTP POST
Simply look at the HTML <form> inside the URL you mentioned, there you have all required POST fields.schimanke wrote:Sounds good. Could you tell me how this is done or where I can find a documentation or example for that. The reason is that I'd like to implement posting comments in my iOS-app which is based on s9y.
What you want to do is basically what all spambots are currently doing. Note that you might face anti-spam measurements; Captcha i.e. cannot be circumvented this way, also the issuing of a cookie will break your external POST request.
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Re: Add comments via HTTP POST
Yeah, I got that. Could you give me an example how such a call would look like? I need only three fields (name, e-Mail, comment).
My current aproach in Objective-C would look like this:
But it doesn't seem to work. What it does is it calls the URL http://www.schimanke.com/index.php?url= ... tober.html and tries to POST "name=Flo&comment=Das finde ich richtig gut!"
I guess I have to specify that it is a comment. But where do I do that?
My current aproach in Objective-C would look like this:
Code: Select all
NSURL *url = [NSURL URLWithString:@"http://www.schimanke.com/index.php?url=archives/3485-DigiTimes-Neuer-iMac-angeblich-im-Oktober.html"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"POST"];
NSData *requestBody = [@"name=Flo&comment=Das finde ich richtig gut!" dataUsingEncoding:NSUTF8StringEncoding];
[request setHTTPBody:requestBody];
NSURLResponse *response = NULL;
NSError *requestError = NULL;
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&requestError];
NSString *responseString = [[[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding] autorelease];
I guess I have to specify that it is a comment. But where do I do that?
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Add comments via HTTP POST
Hi!
Your POST request would need to look like this:
You are missing the serendipity[...] prefix in your Post request, I think.
I think this should work:
Your POST request would need to look like this:
Code: Select all
POST /index.php?url=archives/3485-DigiTimes-Neuer-iMac-angeblich-im-Oktober.html HTTP/1.1
Host: www.schimanke.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:13.0) Gecko/20100101 Firefox/13.0.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Referer: http://www.schimanke.com/index.php?url=archives/3485-DigiTimes-Neuer-iMac-angeblich-im-Oktober.html
Content-Type: application/x-www-form-urlencoded
Content-Length: 291
serendipity%5Bentry_id%5D=3485&serendipity%5Bname%5D=This+is+my+name&serendipity%5Bemail%5D=mail%40example.com&serendipity%5Burl%5D=http%3A%2F%2Fwww.example.com&serendipity%5BreplyTo%5D=0&serendipity%5Bcomment%5D=This+is+my+reply%2C+test+capture.&serendipity%5Bsubmit%5D=Kommentar+abschicken
I think this should work:
Code: Select all
NSURL *url = [NSURL URLWithString:@"http://www.schimanke.com/index.php?url=archives/3485-DigiTimes-Neuer-iMac-angeblich-im-Oktober.html"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"POST"];
NSData *requestBody = [@"serendipity[entry_id]=3485&serendipity[name]=Flo&serendipity[comment]=Das+finde+ich+richtig+gut!&serendipity[submit]=Kommentar+abschicken" dataUsingEncoding:NSUTF8StringEncoding];
[request setHTTPBody:requestBody];
NSURLResponse *response = NULL;
NSError *requestError = NULL;
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&requestError];
NSString *responseString = [[[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding] autorelease];
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Re: Add comments via HTTP POST
Sometimes the obvious is hard to find...
Thanks! It's working now!
Thanks! It's working now!
-
- Regular
- Posts: 695
- Joined: Tue Jul 03, 2007 3:34 am
- Location: Berlin, Germany
- Contact:
Re: Add comments via HTTP POST
Only to mention this: For a client it should be better to use the XMLRPC Api of s9y. If you want to know how, you can have a look at the iOS Wordpress client. It's open source.
But if you want to comment only, POSTing is good enough, I think.
But if you want to comment only, POSTing is good enough, I think.
Re: Add comments via HTTP POST
Yep, it's just about giving my readers the option to post comments through my app. Everything else already works pretty fine. But thanks for your suggestion!