I have a CRM set to crm.example.com And a active store on example.com (on the same server)
Both running with NGINX.
Im trying to request the whole categories list (43 categories) but i'm getting only 10. (The default value set by WooCommerce).
I tried using the per_page parameter but it seems like the server is ignore the GET.
I checked the request sent from crm.example.com and got that:
object(Automattic\WooCommerce\HttpClient\Request)#85 (5) {
["url":"Automattic\WooCommerce\HttpClient\Request":private]=>
string(67) "https://example.com/wp-json/wc/v2/products/categories/?per_page=100"
["method":"Automattic\WooCommerce\HttpClient\Request":private]=>
string(3) "GET"
["parameters":"Automattic\WooCommerce\HttpClient\Request":private]=>
array(1) {
["per_page"]=>
int(100)
}
["headers":"Automattic\WooCommerce\HttpClient\Request":private]=>
array(2) {
["Accept"]=>
string(16) "application/json"
["User-Agent"]=>
string(32) "WooCommerce API Client-PHP/1.3.0"
}
["body":"Automattic\WooCommerce\HttpClient\Request":private]=>
string(0) ""
}
But yet there is only 10 results.
i'm thinking maybe the NGINX server is ignoring the GET parameters as a security policy?
Related
I've been using the Salesforce SOAP API for a number of years, but the original PHP client that Salesforce provided doesn't work with PHP8.1. I've attempted to incorporate the necessary elements of the client into my code since I'm only performing one simple action (creating a QuoteLineItem). I've been able to get the client to properly connect and login, but my create command doesn't get any response (not even a NULL value).
I've compared everything being sent from the PHP7.4 solution and my 8.1 implementation, and they appear almost identical.
Create statement:
$result = $this->sforcePartnerClient->create($arg);
$arg value:
object(stdClass)#1331 (2) { ["__CLASS__"]=> string(8) "stdClass" ["sObjects"]=> array(1) { [0]=> string(26) "\Module\Controller\SObject" } }
Why am I not getting even an error response?
I'm working on a cURL script to communicate with an API. I wrote a script to retrieve the data with a cURL request and the data is displaying as follows. This is just one chunk of the JSON response as there are usually multiple users online. The unique identifier is ["fromAddress"]=> string(18) "127.0.0.1:5060" which is constant no matter what. The CALLID field is unique every time a call is initiated from the server which makes it a real pain!
What I need to with the JSON Response is this:
Get [CALLID] from array# where ["fromAddress"] equals"127.0.0.1:5060"
Save to a php variable.
I'm not sure what the next step is. Can someone please point me in the right direction?
Thanks!
array(35) { ["callID"]=> string(22) "U1A7B9F7T61A2BC05S2eI1" ["callType"]=> string(3) "sip" ["participantID"]=> int(2) ["started"]=> int(15551212) ["updated"]=> int(15551212) ["name"]=> string(9) "TEST CALL" ["notes"]=> string(0) "" ["toNumber"]=> string(12) "+15551313" ["fromUri"]=> string(58) "sip:5551212#127.0.0.1:5060;pstn-params=908481808882" ["fromAddress"]=> string(18) "127.0.0.1:5060" ["fromName"]=> string(15) "WIRELESS CALLER" ["fromNumber"]=> string(12) "+15551212" ["location"]=> string(14) "SOMEWHERE, CO, US"
you posted a result from var_dump and is not complete
usually when receive json from a response you need to convert it to php's object using json_decode since response always return a string instead an object.
$obj= json_decode($response)
then you can access the data like thia
$obj['callID']
$obj['fromAddress']
Folks I think I may miss a dead simple thing but I just have no idea where to look for it.
So I'm trying to implement block.io API to accept bitcoin payments on a website built on PHP. Now the Docs say that all notification events will use JSON objects pushed to my server through POST requests. So I decided to make a test BTC payment and log all requests on a specified URL to my DB. And here what I gen on dumping getallheaders()
{
["Content-Type"]=>
string(16) "application/json"
["User-Agent"]=>
string(12) "Block.io/0.1"
["Accept"]=>
string(10) "text/plain"
["Authorization"]=>
string(10) "Basic Og=="
["Connection"]=>
string(5) "close"
["Host"]=>
string(17) "site.com"
["Content-Length"]=>
string(3) "462" }
But dumping $_POST gives me an empty array. Dumping $_SERVER and $_GET gives nothing useful either.
So my question is how can I find the JSON string declared in Content-Type?
Any suggestion would be helpful!
Thanks!
Because the Content-Type is application/json (not application/x-www-form-urlencoded)
$inputJSON = file_get_contents('php://input');
EDIT: excellent explanation at PHP "php://input" vs $_POST
I have a site where I fetch reddit comments using Guzzle and Reddits json api. While it tends to be really slow, it works, but I've run into an issue when trying to load more children via the /api/morechildren.json endpoint.
I always receive a 403 forbidden error when trying to get more children. These are the params I am using including the data and the endpoint which I am hitting.
array(2) {
["request"]=>
string(44) "https://www.reddit.com/api/morechildren.json"
["data"]=>
array(6) {
["link_id"]=>
string(10) "t3_cz36xw7"
["id"]=>
string(10) "t1_cz361ai"
["depth"]=>
string(1) "1"
["children"]=>
string(7) "cz36xw7"
["sort"]=>
string(10) "confidence"
["api_type"]=>
string(4) "json"
}
}
You can see the api I'm trying to hit here: https://www.reddit.com/dev/api/oauth#GET_api_morechildren
No matter what I try, i get 'string(116) "Client error response [url] https://www.reddit.com/api/morechildren.json [status code] 403 [reason phrase] Forbidden"'
Any ideas?
Authentication is needed. OAuth is authorisation library but hard to use without 3rd party library. Look at https://github.com/OAuthSwift/OAuthSwift, it's a good authorisation library and easy to use.
I am sending POST data to a php page and receiving it by var_dump($_POST). However the $_POST is always empty and the $_GET contains the values. I'm certain its a POST request and have tested in Postman REST client and cURL. I am using PHP 5.5.3 and Apache 2.2.
Thanks
EDIT:
I'm using the php scripts as an api so currently I am testing using the above mentioned tools to test the request using POST.
For example I am using this cURL request curl -X POST http://dev/project/build/api/registrants.php?hello=there
Contents of my $_SERVER (redacted in areas)
array(25) {
["HTTP_USER_AGENT"]=>
string(11) "curl/7.37.1"
["HTTP_HOST"]=>
string(3) "dev"
["HTTP_ACCEPT"]=>
string(3) "*/*"
["PATH"]=>
string(29) "/usr/bin:/bin:/usr/sbin:/sbin"
["SERVER_SIGNATURE"]=>
string(0) ""
["SERVER_SOFTWARE"]=>
string(67) "Apache/2.2.25 (Unix) mod_ssl/2.2.25 OpenSSL/0.9.8za DAV/2 PHP/5.5.3"
["SERVER_NAME"]=>
string(3) "dev"
["SERVER_ADDR"]=>
string(9) "127.0.0.1"
["SERVER_PORT"]=>
string(2) "80"
["REMOTE_ADDR"]=>
string(9) "127.0.0.1"
["DOCUMENT_ROOT"]=>
string(25) "/Applications/MAMP/htdocs"
["SERVER_ADMIN"]=>
string(15) "you#example.com"
["SCRIPT_FILENAME"]=>
string(59) "/Applications/MAMP/htdocs/project/build/api/registrants.php"
["REMOTE_PORT"]=>
string(5) "51096"
["GATEWAY_INTERFACE"]=>
string(7) "CGI/1.1"
["SERVER_PROTOCOL"]=>
string(8) "HTTP/1.1"
["REQUEST_METHOD"]=>
string(4) "POST"
["QUERY_STRING"]=>
string(10) "hello=there"
["REQUEST_URI"]=>
string(45) "/project/build/api/registrants.php?hello=there"
["SCRIPT_NAME"]=>
string(34) "/project/build/api/registrants.php"
["PHP_SELF"]=>
string(34) "/project/build/api/registrants.php"
["REQUEST_TIME_FLOAT"]=>
float(1416256385.03)
["REQUEST_TIME"]=>
int(1416256385)
["argv"]=>
array(1) {
[0]=>
string(10) "hello=there"
}
["argc"]=>
int(1)
}
In your <form> tag, make sure the method="POST" attribute is present.
Well, I was having the same problem and I discovered that the error was that I was using the wrong headers and the variables should be passed in the body of the request and not as URL parameters. I was using Postman to generate POST requests and I was getting $_GET filled and $_POST as (array(0)), so I read about $_POST superglobal and and it only gets filled when using application/x-www-form-urlencoded or multipart/form-data as the HTTP Content-Type in the request, according to PHP documentation here: http://php.net/manual/en/reserved.variables.post.php. Then, I read the Postman manual and it shows at the print screens that the parameters must be at the body as explained here at the session request body: https://www.getpostman.com/docs/v6/postman/sending_api_requests/requests. As said by steve on his comment on your question, using curl this request should be formatted like this:
curl -X POST --data "param1=value1¶m2=value2" https://example.com/resource.cgi