ghassani / surveymonkey-v3-api-php Goto Github PK
View Code? Open in Web Editor NEWSurveyMonkey v3 API Wrapper
License: GNU General Public License v3.0
SurveyMonkey v3 API Wrapper
License: GNU General Public License v3.0
Does this package need Guzzle 6.2.2 specifically for some reason?
I have created a survey on Survey Monkey. And added a custom variable. The collector is a weblink appending the custom variable to it.
I want to check if a user has completed the survey or not. If someone has completed the survey then they are redirected to the homepage and if not then they are redirected to the survey page. I'm passing the CustomerID in my redirect if users have not completed the survey.
I want to be able to check if this CustomerID is in the list of responses. I'm able to get the bulk responses in my Get request But is there a way I can just check directly if this CustomerID exists in my completed list. Bulk Request: https://api.surveymonkey.net/v3/surveys/1234/responses/bulk
Often the Surveymonkey API returns a "next" field.
The API does however not provide a method to call the "next" URL.
For example, I want to get all survey responses, in few requests. Using get Collector/bulk with details allows to get a max of 100 responses through the api. The Result set could provide a "getNext()" method, that fetches the next 100 responses.
Thanks for this lib, it's looking promising for my use case so far!
I would create a PR for this but I'm not yet 100% clear on the best way to resolve it.
The behaviour I expected was that I could pass object_ids
as a key of the array passed to createWebhook()
and have it passed on in the request object like
{
...
object_ids: ["1234"]
...
}
But because Client::createRequest()
does the encoding from the input array and adds the JSON_FORCE_OBJECT
flag, the current behaviour seems to be this:
{
...
object_ids: {"0": "1234"}
...
}
This is rejected by the API with an invalid schema error.
One workaround is to do my own json_encode()
without the flag and pass in the string, but this generates a warning since the public method declares its argument as an array
. (I'm still on PHP 5.6 for this project unfortunately - haven't checked what happens on 7.x yet.)
As things stand, I don't think it's possible to pass in the correct param type while setting this filter for the new webhook successfully.
If you don't see obvious BC breaks for other methods, I'm thinking the cleanest solution might be:
createWebhook()
's array $data
param to an object with (object)
- leaving any nested arrays and objects untouched with their original typesJSON_FORCE_OBJECT
flag from Client::createRequest()
when encoding array inputsWhat do you think?
It appears that on 5/23, SM moved their platform to AWS Cloudfront which rejects requests that have an empty json body. My application uses SM webhooks to get notified that a new response is ready to download. We download survey responses many times per day. Our application started getting the 403s and returned false getData() calls around the same time. I submitted a support ticket to SM and got the attached response.
For some reason SM also change our access_token.
I changed Client.php, updated our access code and tested and all was ok. I will follow up with a pull request for review. Here is my attempt at a revised function.
private function createRequest($method, $uri, array $options = [], $body = null)
{
/*
Survey Monkey moved to CloudFront on 2020-05-23
CloudFront issues 403 Forbidden with empty json body
*/
$ret = new Request($method, $uri, []);
if (is_array($body)) {
$bodyString = json_encode($body);
}
if (isset($options['query'])) {
$uri = $ret->getUri()->withQuery(is_array($options['query']) ? http_build_query($options['query']) : $options['query']);
return $ret->withUri($uri, true);
}
return $ret;
}
$options = ['per_page'=> 200];
$results = $client->getSurveys($options);
When calling the getSurveys method of the Client the options seem to be completely ignored.
See pull request 24
Can you add version 1.0.0 please ?
Hello !
On the last tag (1.0.2), the method src/Api/ResponsesTrait.php::getSurveyResponse
doesn't work anymore since i upgraded package guzzlehttp/guzzle
from 6.2 to 6.4 (this exception is thrown : "Header value can not be an empty array.").
It's working fine on master though, so can you make a tag please ? (i have to set a commit in composer now)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.