Facebook Delphi - delphi

Trying to post data to https://www.facebook.com/login.php using synapse delphi library but without any result. The post data was got from mozila headers viewer.
Answers?

I assume you already know how to use HTTP Post with Synapse. If you also need HTTPS support, you will need at least release 36, and change some settings, such as port. Here is an example using TCP.

Related

Delphi how to avoid sniffers

I'm developing a project with Delphi 2010, at some point this project connects to internet and send some data to a php file via POST/IDHTTP, those parameters encrypted with aes and as you know there is no way to get source code of php files via browser. But when i use sniffer on my project sniffer software shows full path of php file and parameters. I was wondering is there any chance to hide path and parameters with IDHTTP. For example when i try on Skype sniffer only shows decimal characters on skype's transmission. Is it possible to do same or totally hide the traffic ?
Thanks in advance.
You can use HTTPS, it is supposed to be standard way to transmit HTTP traffic through SSL-protected channel. Example of code you can find for example here.
In addition to Andrei's answer, you can consider encrypting your traffic on-top of using HTTPS.
In other words,
1) Use HTTPS protocol.
2) Add your own layer of encryption to encrypt all data coming to and from your server.
In addition to HTTPs and encrypted data, you can also add security by using client certificates. See https://security.stackexchange.com/questions/3605/certificate-based-authentication-vs-username-and-password-authentication
The answers explain the advantages of using CBA, one of them is
certificate usage never involves revealing any secret data to the
peer, so an attacker impersonating the server cannot learn anything of
value that way

Is there a way to browse WSDL endpoints using a browser?

I want to test the results from a WSDL service in a browser like IE9 or FireFox. I know that I can view the WSDL XML, but I want to test the return results of an endpoint called GetEmployeeById that accepts a parameter called Id and returns a class. I am assuming this is all serialized to XML, so a browser would be a good fit for testing this. Is this possible?
In case you are using Visual Studio for .net development, I think something much better than a browser probably would to use:
wcftestclient <url>
which can be called from the command prompt and is part of the tools from visual studio.
The tool will help you to build and receive complex objects and see the results already serialized.
internet explorer let's you make a request with simple string parameters if the WSDL provides enough information.
If you haven't seen it, then probably the WSDL is only for discoverability reasons, probably just points to another service in a different transport protocol, not port 80, if the service is not on port 80 you won't be able to use your browser.
You have another more complex tool called FIDDLER that you can format any kind of http request, as well as receiving any kind of requests, like json for example.
You can use this URL to test WSDL endpoints, send request and see response.

Delphi - Connecting and logging in to a webpage

EDIT
There has been quite a development. The current problem is this:
I compared requests sent from a browser and sent from my app. There have been some differences and I managed to correct most of them. Some are still unfixed, since I haven't figured it out how yet. I am using INDY.
How can i send (or add) cookies into the request?
I tried this:IdHTTP.CookieManager.AddCookie('bakatheme=BrectanTheme',IdHTTP1.URL) but it doesn't work. Also, in INDY help they say that it is supposed to be AddCookie(String, String), but my Delphi only accept (String, TIdURI) - I am not sure if it is the right URI I am calling.
In the Headers I have this code: AcceptEncoding:='gzip,deflate,sdch'; yet when I parse the outgoing request, it states this: AcceptEncoding:gzip,deflate,sdch,identitybut I am certain I don't have "identity" anywhere in the code.
Those are the two things in which my request differs from the browser's. Now, I am getting a 500 Internal Server Error at return, can it be caused by the lack of cookies or the second thing?
Thank you very much.
Haven't exactly tried it myself but here's an example I found about website login using indy
http://www.ciuly.com/delphi/indy/persistent-login-example-for-geocacheing-no-ssl/
Ok. Lets comment:
How can i send (or add) cookies into the request?
You should not do that. Indy handles this for you (but if really want to, there is a TidCookieManager). But it seems to me that you dont know how cookies work. Its not a thing you can add to a request. It cames from the server and it identifies you.
In the Headers I have this code: AcceptEncoding:='gzip,deflate,sdch';
AcceptEnconding tells to the server that it can compact the response using those algorithms. Indy supports gzip,deflate,sdch,identity and indy is updating que header request to add the one you forgot to put.
You should take a look at those links to learn how http works:
W3
Wikipedia

Wall on FaceBook

i would like to post a message on facebook wall (standard friend/group's wall) not the Apps. using delphi, i could log-in but i dont know how to post a message on it. any suggestion?
I have never used Delphi so im not sure about the language structure
but facebook API is basically HTTP Requests, you should be able to build a class that upon instanation you would authorize your app and then have a set of methods that publish data via HTTPRequest and validate the response
Heres something you may wish to look at:
Facebook emailer in delphi via CakeMail: http://www.facebook.com/note.php?note_id=17522112271
And how to post via HTTP:
http://developers.facebook.com/docs/reference/api/post
It is possible.
If you're able to login you can use a sniffer to take a look for the details of how it is accomplished by Facebook itself when you do it withing a browser (kind of reverse engineering). Wireshark is the best tool for me.
Look and take your time to understand what's going on between your browser and the servers when you post messages to your friend's wall.
Once you understand the details, you can mimic the exact same behavior from your Delphi program to get the same results, for example with the TidHTTP or TidTCP components.
Facebook is AJAX intensive: series of HTTP GET/POST operations without full page refreshes.
Don't forget you're mimicking a undocumented and internal communication mechanism. Facebook or any other target site may change it's internal's and broke your program compatibility anytime.
Remember this kind of program may be prohibited... read the facebook agreement's for further details.
delphibook is a Delphi library to support Facebook applications.
Two possible links that may provide some guidance? They are not in delphi, but I assume the api would be similar to javascript/php ?
http://daipratt.co.uk/using-fb-api-to-make-a-full-post-to-a-users-wall/
http://blog.theunical.com/facebook-integration/5-steps-to-publish-on-a-facebook-wall-using-php/

How to get the status header for a website programmatically

I am writing a win32 service in Delphi (should be able to translate any other code if you don't know delphi) that needs to fetch the status of a website. I know how to do this in .NET but am not sure with normal windows based programming. So, I need to query a website and return the Status Code 200, 301 ect. My plan is then to parse the data returned and send an email should one of my sites go down.
Can someone lend a hand?
EDIT: This is the code I used in the end - using the TIDHttp Indy component.
IdHTTP.Get('http://www.example.com');
if IdHTTP.Connected then begin
ResponseCode := IntToStr(IdHTTP.ResponseCode);
ShowMessage(ResponseCode);
end;
Take Indy or Synapse library (both are free, indy is included with Delphi, synapse is found on google) and use their HTTP client class to do the job.

Resources