Replicate request payload with cURL, PHP [duplicate] - php

This question already has answers here:
RAW POST using cURL in PHP
(2 answers)
Closed 3 years ago.
There is a website that when you fill some form, it send a xhr request with some content of the form in the payload header. The content is similar to this one (not exactly this, this one was extracted from another website, but the same format of content separated with pipes):
7|0|5|https://www.bosscapital.com/app/Basic/|B8CC86B6E3BFEAF758DE5845F8EBEA08|com.optionfair.client.common.services.TradingService|getAssetDailyTicks|J|1|2|3|4|2|5|5|CB|U9mc4GQ|
I want to replicate this request with cURL but I don't know how to do it. I don't know the name of the input fields (because the have no name in the HTML code and I can't find the request on the JS).
I was looking at some Stack Oveflow treads like this, this or this, but still is not clear for me how to do it.
Hope you can help.
P.D.: I know how to use cURL, but I din't even know this Request Payload thing before this job was assigned to me.

I strongly recommend you to use Postman to run your call (or see the curl version)
https://chrome.google.com/webstore/detail/postman/fhbjgbiflinjbdggehcddcbncdddomop
with the interceptor to catch the XHR request https://chrome.google.com/webstore/detail/postman-interceptor/aicmkgpgakddgnaphhhpliifpcfhicfo

Related

Handling of the post request and execute another script in PHP [duplicate]

This question already has answers here:
How do I close a connection early?
(20 answers)
Continue PHP execution after sending HTTP response
(13 answers)
Closed 9 years ago.
So I have a PHP script that handles post requests. It works quite good, but (always a but) the data I am receiving is encoded. I need to run an external program to decode it. That also works.
My problem is, that my client connects to the server, does a POST and waits for the OK reply from the server, to verify that the post request has been handled correctly. Now when I add the part of the Decoder into my POST request handling script, it takes some time for my client to receive the OK from the server. It is only sending it back when the entire script has been finished, and not only the uploading of the files part, understandably.
What I was wondering now, can I do this in another way? When the uploading of the files is done, the client should now that the upload is finished. He should not have to worry about the decoding part. I also need it to decode immediately after the POST request has been handled, so I'm a bit puzzled at how I need to do this...
Don't really think I need to give out my code but if the need should arise i'll be glad to oblige.

How to scrape a javascript site using PHP, CURL [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How do I render javascript from another site, inside a PHP application?
This is the site http://www.oferta.pl/strona_v2/gazeta_v2/ . This site is built totally on JavaScript. I want to scrape using PHP and curl. Currently I use DOMXPath. In the left menu there are some category to be selected. I see no 'form' there. How can I use curl to submit that form and scrap the output page?
I have used file_get_contents() only. It doesn't get all of the page. How can I proceed?
N.B : http://www.html-form-guide.com/php-form/php-form-submit.html I have found this example which have a 'form'. But my specified site has no 'form'.
You can not scrape it. Its possible. But its way too hard.
Simulate the http request by curl. Check every request it makes by ajax and try to simulate it.
Simulate Javascript executions (this part is almost impossible). Some requests contains values which are generated by Javascript. You need to do it in php. If they has some complicated algorithm implemented in JS you can invoke v8 javascript engine.

Test Connection to YouTube Servers with JavaScript or PHP [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Detecting if youtube is blocked by company / ISP
Is there a way to test if a user's browser has access to YouTube servers using JavaScript or PHP?
Some companies block access to certain sites, like YouTube for obvious reasons, and therefore it's necessary to stream fallback videos from a different CDN if that is the case. I currently have a solution using ActionScript, but I would prefer to use PHP or JavaScript to replace the div instead if that's possible.
EDIT:
As #NathanKleyn said the php code below wil only check if your server has access to youtube, not the client that's using your tool. If this is what you want (which i guess it is after re-reading your question) the javascript solution below should be a solution too.
var request = new XMLHttpRequest();
request.open('GET', 'http://www.youtube.com', false);
request.send(null);
alert(request.status);
One way to achieve this is to request the headers on youtube.com with PHP's get_headers(), check if the HTTP code returned to determine if the site is accessible.
You could probably do this with curl too though it is more complex, yet alot faster.

Send iPhone data to PHP file [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicates:
iPhone: Post data to php page
Passing Data From iPhone app to PHP file
What is the best way to send simple numerical and textual data from an iphone app to a php application?
Essentially what I am trying to do is to get the data input by users sent to a php file so it can be stored in a remote database.
What is the best way to send data from an iphone app to a php app so it can be stored in a MYSQL database...
assuming you know which fields are being sent, there is nothing to stop you sending the data via post, but make sure you validate/sanitise on the php side.
if you choose to go this route, I would have a look at http://allseeing-i.com/ASIHTTPRequest/
You will want to use NSURLRequest to post data to a PHP file on your server. There are also some libraries out there such as http://allseeing-i.com/ASIHTTPRequest/ which you could use instead.

What is the difference between JSON and JSONP? [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Please explain JSONP
For example in the jQuery documentation I find both JSON and JSONP mentioned. What is the difference exactly? How can I see which is which? Which one should be used for what?
And what does the PHP function json_encode generate?
JSON is a simple data format. JSONP is a methodology for using that format with cross-domain ajax requests while not being hit by Same Origin Policy issues. Basically, the idea is that instead of using ajax to request JSON-encoded data, you add a script tag to your page that loads the data as a JavaScript script and makes a callback to your code saying "Here's the data." This works because the "origin" applied to JavaScript scripts is the origin of the document, not where the script came from, which means it can access your code in order to call the callback.
json_encode produces JSON. You might use json_encode as part of providing a JSONP interface to your system, if you need to enable cross-domain calls.
See also CORS, which may increasingly be used for this instead as we go forward, but which isn't yet supported well in IE (IE7 and below don't have it at all; IE8 has it but requires that the client-side code do special things; Chrome, Firefox, and the like have it and don't require the client-side code to do anything special).

Categories