Send information to website server programmatically - c#

I have very minimal experience with anything web related so apologies if this is a silly question.
I have a Wordpress site with a contact form which users can use to send me a message from the website. The user fills out the form, and it is converted into an email and sent to me.
I would like to have similar functionality from my c# desktop application.
In other words, I am looking for a way to either programmatically invoke the contact form on my website, or to send information to my website, which it will convert into an email and send it to me directly.
What general concepts should I be looking into?

The information typed into the web form is probably sent back to the web server using the HTTP POST method. Essentially the data entered into the web form is converted to name values pairs and sent to the WordPress app. More information on HTTP POST here: HTTP POST (Wikipedia)
To do the same from a C# app, you need to format the data to POST in a similar way and then look at using the HttpWebRequest class. This stackoverflow thread shows an example: HTTP request with POST. If you POST the information to the same URL the web page is using then the server should generate the email.
Just to note as well, if the WordPress app requires you to be logged in before submitting the information, then you'll need to include code to authenticate with the WordPress app within the C# app.
I hope this helps!

Related

How to send data windows form application to website

i am creating an windows application in c#.
in this application i am creating an feed back form for client feedback.
now i want to submit all data this feedback form to my on site.
The the puzzle is that my website is in PHP .
should i go with this combination?
i min c# app and PHP website and sent data via url and grab it on site using GET method, or i need to create a separate website in asp for this action and if you say YES the please tell me .
how to do this action in ASP
thanks
You can simple send a Get/Post-Request to your PHP-Page:
Generate HTTP Requests using c#
and then Read the data via: $Get or $Post.
You can do the same with ASP.Net, via QueryString:
string cParam = Request.QueryString["param"];
Your Website language doesn't really matter as long as you code to get the proper form values. You can use a GET or a POST as well based on type and quantity of data sent across.
You can HTTPRequest and HTTPResponse classes to send response to the Website.
I just got the answer . This question may already have an answer here
pass string from C# Windows Form Application to php webpage
Use Same Data base, and place data from window application and get it from web application

Requesting a recaptcha and caching the image

I need to create a WCF application that requests a "recaptcha" and sends it over to a WCF client, as a bitmap. All examples I have found so far are built to display the captcha in a web browser, wheras I need the actual recaptcha image.
The reaason I need to do this is because I need to create a registration screen in a c# WinForms application. Here's how it works:
User opens registration screen through windows application.
Application requests a captcha from WCF server.
WCF server generates and sends captcha.
Application displays captcha and allows user to enter details.
Application sends details and captcha code to server via WCF.
Server sends return code (ie: If registration was successful or if it failed.)
Note that a hosted website is not an option at this point. There is only a WCF server and a WCF client. I have been trying to avoid generating my own captcha and using re-captcha instead, but I have not managed to find a way to download the actual captcha image. Any alternative solutions are welcome.
It's actually quite similar to this:
https://stackoverflow.com/a/12154911/518923
As the answer suggests, use http://www.google.com/recaptcha/api/challenge?k=your_public_key to get the challenge, parse ChallengeValue, then you can get the image via http://www.google.com/recaptcha/api/image?c=challenge_value
Afterwards you can verify the challenge via http://www.google.com/recaptcha/api/verify
Make sure to check the documentation on the subject https://developers.google.com/recaptcha/docs/verify
Shamelessly copied from the linked post, but I will take no credit ;)

winform facebook app accept friend request

I am using facebook-c#-sdk to develop a winform FaceBook app, this app should be able to accept friend request and chat with people.
But I didn't find any samples on how to access friend_request in the facebook-c#-sdk.
Can someone help to point out how could I accept friend request?
And especially how can I get the notification first and then accept the request?
Extra information:
The API, [facebook-C#-SDK] is officially supported by Microsoft
http://developers.facebook.com/tools/third-party-sdks/
I already check out the following post but found no solution to my problem.
Accept or decline Friend Request using FB Graph API
If you like, you can chat with my bot during office hour, it works only if I manually accept your friend request.
http://www.facebook.com/ictbot.np
AFAIK, consistent with Igy's link, there is no way for an app to send, accept or refuse a friend request. This is one of many capabilities which Facebook presumably does not consider appropriate for apps.
See https://developers.facebook.com/docs/reference/fql/friend_request/ on reading friend requests using the API, including the considerable limits on doing so.
Thanks Jon Newman for pointing out the limitation of API.
Basically there is no way to do so with Facebook API.
But I do have a workaround, and this workaround only works for certain scenario:
"When you have full control of a facebook account"
In my case ,the app is used only by my Facebook account. I have full control of both, so I will set the notification on in account setting.
When a friend request is send to my facebook, the notification is also send to my gmail.
Then I can retrieve it from gmail, filter out html tag, then a link will appear, open that link in browser.
Done.
Miscellaneous:
1)To retrieve email in gmail:
http://imapx.codeplex.com/releases/view/98061
Basicly Program.ImapClient.Folders[0].Messages[#].HtmlBody.TextData will give you the html data.
2) If your url is wrong, you will be redirected to friend request list where you can accept request manually.

c# authenticate phpbb forum user in application

I would like to have a simple authentication on my software. I know I will need to use HttpWebRequest and send the post data/ headers, but I have not been able to figure it out.... does anyone have any examples?
Sorry about the lack of information. I have been able to resolve the issue by creating a custom phpbb forum login php page that takes username / password parameters and I send the request from my software application to this php I've created and wait for the response and see if the php was able to validate the login.
There is a better way, Unfortunately I lost my Phpbb application, but it was based on the code provided Here
It creates a header for phpbb, and stores the cookies, allowing you to do alot with it.

C# Forms authentication with form data

I have two applications, say app. A and app. B. App A. sends form data (using the post method) to app B. B however, is a web application and uses forms authentication. The post data is send to a webpage (viewdocument.aspx) which is secured by forms authentication. But when the data is send to viewdocument, the login page is displayed because the user isn't authenticated.
The point is, I want the post data to be read by viewdocument. How can I do this?
You can allow all users to access your viewdocument page (by setting authorization in your web.config), get the values of the post in your page load and then, manually do:
if (!User.Identity.IsAuthenticated)
FormsAuthentication.RedirectToLoginPage();
//Else continue with page display
This way, you will protected the display of your page but be able to send data to the page with any user.
I hope it will help
If your web app is only for accept data use web-services.
I think you want to consider separating out the two process - accepting data from another web site, and displaying data to a user. This way the you get nice separation of logic which can improve maintainability. And I'm not sure how you are going to go POSTing data from one website to another as POST should go back to the original webpage. I would do as #Kane suggested in his comment and use a service to accept the incoming data. This could be built to accept the current data, but would also be easily extensible if you ever need to receive data from other sites. Your page for displaying the data would then be a lot more simple and clearer for developers to work on.

Categories