Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
I am using a library to make API call to the Instagram API. And I am getting a response like this:
POST: https://i.instagram.com/api/v1/feed/timeline/
DATA: is_prefetch=0&feed_view_info=&seen_posts=&phone_id=4c14088a-94b7-49c3-bec3-12caad443c50&reason=pull_to_refresh&battery_level=100
← 200 15.19kB
RESPONSE: {"response": "Random Json Response"}
I want the value of the response key from here.
What is the strategy to parse it? Or this is a special kind of software architecture style like SOAP or REST?
What you're probably looking for is the apache_request_headers() function.
You would use it like so:
$response = apache_request_headers();
print_r($response);
This will generate an array where you will be able to retrieve the information that you need.
The RESPONSE: data is in the JSON format. So you will need to convert it to an array like so:
$responseData = json_decode($responseData, true);
print_r($responseData);
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 days ago.
Improve this question
Post request empty data receiving through postman Api With codeigniter 3 it turns into get request.
Post Request Automatic Converted Into Get Request.
$_POST or $this->input->post() is receiving as an empty array !
I tried it from php curL or many ways but always get as an empty array !
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I was trying to build a script that could get me definitions of words from the wikipedia API in php.
I tried several obtaining the definitions in an array and displaying the first definition but it didn't work. Can anyone please help me out. Any help is appreciated
Which parameters did you use in your request?
You can take this as an example:
https://en.wikipedia.org/w/api.php?action=opensearch&search=PHP&limit=1&format=json
You said there that you want only the first definition, so you can put limit=1. The response is in json.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
Am fetching data from mysqlite to a string array which i want to submit to PHP then update a mysql table.
Any easy way out, because doesn't seem to work?
I suggest using the network monitor tool to see that the Codename One code is sending out the right data as explained in the IO section of the developer guide.
I notice your PHP code tries to decode JSON into an array whereas your Java code adds a POST array both of which have nothing in common. I don't really know PHP's equivalent for handling an array so I can't help you there. On the Codename One side you can just write the array as JSON by converting it to a JSON String.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I have created that needs to take post values and return a JSON encoded array.
That all worked fine until I was told I would need to post the form data with a content-type of application/json.
Since then I cannot return any values from the web service and it is definitely something to do with how I am filtering their post values
Basically I know that it is due to the $_POST values not being set but I can't find what I need to put instead of the $_POST. I tried json_decode($_POST), file_get_contents("php://input") and a number of other ways but I was shooting in the dark a bit.
Any help would be greatly appreciated.
You have empty $_POST. If your web-server wants see data in json-format you need to read the raw input and then parse it with JSON decode You need something like that
$input = file_get_contents('php://input');
$result = json_decode($input);
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I serialize some object in .NET using JsonSerializer (on a Windows machine)
The serialized string looks like this:
{
"ItemId":"someID",
"Properties":
{
"Title":"someTitle",
"Text":"someText",
"Time":"someTime"
}
}
Then I send it to a my Linux server, using HttpWebRequest.
On the Linux side I run PHP (using LAMP), when I get it on PHP server the Json string looks exactly as it looks before I send it, but when I try to decode it ( using json_decode($myJsonStr, true) ) I get Syntax Error.
My Json also include some Unicode characters (Hebrew letters)
Any ideas?
Best Regards, Nadav
I'm not sure how you filled your $myJsonStr, but sometimes it's best to decode JSON taking the input directly from PHP's streams, like this:
$data = file_get_contents('php://input');
$json = json_decode($data);
This is the way I use to get around one of those incompatibilities when receiving JSON from third-parties.