I'm working off this documentation: http://docs.amazonwebservices.com/AWSSDKforPHP/latest/#m=AmazonEC2/modify_instance_attribute
This is the best I can make sense of the docs:
$instance_id = 'i-XXXXXXXX';
$volume_id = 'vol-XXXXXXXX';
$ec2->modify_instance_attribute ( $instance_id, array(
'Attribute' => 'blockDeviceMapping',
'BlockDeviceMapping' => array(
array(
'DeviceName' => '/dev/sdh',
'Ebs' => array(
array(
'VolumeId' => $volume_id,
'DeleteOnTermination' => true
)
)
)
)
));
But the call returns with
[Error] => CFSimpleXML Object
(
[Code] => InvalidParameterCombination
[Message] => No attributes specified.
)
Your code is correct as such: I copied it verbatim, changed nothing but $instance_id and $volume_id (as well as DeviceName to an existing one on an Amazon EC2 test instance) and it returns properly with HTTP status 200.
Are you sure you are running the latest AWS SDK for PHP (not that I'd be aware of a specific issue, but that's the one which is working for me right now)?
Related
I am integrating PayPal Checkout which works nicely unless I include a custom payee in the order body. I tried the PayPal PHP example at https://developer.paypal.com/docs/checkout/integration-features/custom-payee/ that looks like this:
return array(
'intent' => 'AUTHORIZE',
'purchase_units' =>
array(
0 =>
array(
'amount' =>
array(
'currency_code' => 'USD',
'value' => '220.00'
)
),
array(
'payee' =>
array(
'email_address' => 'payee#email.com'
)
)
)
);
Trying to create an order will lead to this error message (which seems to be completely wrong as it complaints about fields that are neither there nor needed):
{"name":"INVALID_REQUEST","message":"Request is not well-formed, syntactically incorrect, or violates schema.","debug_id":"65a47f1e8defd","details":[{"field":"/purchase_units/1/amount","value":"","location":"body","issue":"MISSING_REQUIRED_PARAMETER","description":"A required field / parameter is missing."}],"links":[{"href":"https://developer.paypal.com/docs/api/orders/v2/#error-MISSING_REQUIRED_PARAMETER","rel":"information_link","encType":"application/json"}]} [/var/www/web15/htdocs/retroplace/vendor/paypal/paypalhttp/lib/PayPalHttp/HttpClient.php:215]
If I remove the portion with the payee, everything works fine. But I need the payee in the order...
Do you have PHP errors/warnings enabled? that looks like it might be bad PHP syntax
Try putting:
'payee' =>
array(
'email_address' => 'payee#email.com'
)
Within the array above (second key, in the same array as 'amount')
I have implemented the Google API in PHP as a service and using the Google_Service_ServicePeople() to add a contact. That works and I am getting back a proper result as a paople object. In addition when I call the people_connections->listPeopleConnections method I am getting back the contacts that I have created in my tests. However, when I go to contacts.google.com no contact will be shown.
Maybe it is a missunderstanding from my site, but I thought that based on the appsettings on my account, the new contacts will be created (added) to my account, won't they?
$client = new Google_Client();
$client->setApplicationName ('VABS-CONTACT-TEST');
$client->setAuthConfig($_SERVER['DOCUMENT_ROOT'].'/includes/classes/Google/auth.json');
$client->addScope (Google_Service_Peopleservice::CONTACTS);
$peopleService = new Google_Service_PeopleService($client);
$person = new Google_Service_PeopleService_Person();
$name = new Google_Service_People_Name();
$name->setDisplayName ('FirstName LastName');
$name->setFamilyName ('LastName');
$name->setGivenName('FirstName');
$email = new Google_Service_People_EmailAddress();
$email->value = 'xxx#xxx.xx';
$person->setNames ($name);
$person->setEmailAddresses ($email);
$result = $peopleService->people->createContact ($person);
The response looks like:
Google_Service_PeopleService_Person Object
(
[collection_key:protected] => userDefined
[addressesType:protected] => Google_Service_PeopleService_Address
[addressesDataType:protected] => array
[ageRange] =>
[ageRangesType:protected] => Google_Service_PeopleService_AgeRangeType
[ageRangesDataType:protected] => array
[biographiesType:protected] => Google_Service_PeopleService_Biography
[biographiesDataType:protected] => array
[birthdaysType:protected] => Google_Service_PeopleService_Birthday
[birthdaysDataType:protected] => array
[braggingRightsType:protected] => Google_Service_PeopleService_BraggingRights
[braggingRightsDataType:protected] => array
[coverPhotosType:protected] => Google_Service_PeopleService_CoverPhoto
[coverPhotosDataType:protected] => array
[emailAddressesType:protected] => Google_Service_PeopleService_EmailAddress
[emailAddressesDataType:protected] => array
[etag] => %Eh8BAgMEBQYHCAkKCwwNDg8QERITFBUWFzUZNDciJScuGgwBAgMEBQYHCAkKCwwiDFFrVXd2SnRpTFZZPQ==
[eventsType:protected] => Google_Service_PeopleService_Event
[eventsDataType:protected] => array
[gendersType:protected] => Google_Service_PeopleService_Gender
.
.
.
.
(
)
[modelData:protected] => Array
(
[metadata] => Array
(
[sources] => Array
(
[0] => Array
(
[type] => CONTACT
[id] => 494c65970e1a12eb
[etag] => #QkUwvJtiLVY=
[updateTime] => 2018-04-04T13:58:27.710001Z
)
...
Using the
$peopleService->people_connections->listPeopleConnections('people/me',$options)
lists all the created contacts as expected.
But on my contacts.google.com page no contact will be shown. I am logged in as the same user I have created and granted access to the API.
Any ideas, hwy the contacts won't be shonw on contacts.google.com?
Many thanks!
After several tries it wasn't possible for me to get it solved. Therefore I have tried it now via the RapidWeb Solution. Now it is working and "the setup" with a guide - even though it tooks also 3 steps of getting the right account in place - is simple.
The main problem I had is to understand the logfic of OAuth2 and their possibilities to setup the correct OAuth2 Client.
In my case I needed to setup a Native Client (just choose "Other" as ApplicationType on the second screen in the Google API Console after creating a new OAuth2 ClientId)
Anyway. Many thanks for all who tried to help me! Much appreciated!
Cheers!
I know this type of question has been asked a number of times. I have spent several hours reading and trying the offered solutions - but none appear to work for my situation.
I need to send a SOAP request to an API that can contain an element that repeats like so:
<operationNumbers>
<operationNumber>1234</operationNumber>
<operationNumber>1235</operationNumber>
<operationNumber>1236</operationNumber>
<operationNumber>1237</operationNumber>
</operationNumbers>
I did read that perhaps I could do this:
$buildRequest = Array(
'myheader' => Array(
'date' => MY_DATE,
'id' => Array(
'client' => CLIENT,
'clientRef' => MYREF
)
),
'operationNumbers' => Array (
Array('operationNumber' => '1234'),
Array('operationNumber' => '1235')
)
);
$request = $client->__soapCall( 'getMultiOpDets', array($buildRequest) );
Sadly this does not work and results in 'invalid request', if I send in a single operation number eg:
...
'operationNumbers' => Array (
'operationNumber' => '1234'
)
...
The request is successful. I've tried soapVars/soapParams but cannot get it working using this approach. Any hints/tips/help appreciated.
So, I solved it.
$operationNumbersArray = array('1234','1235');
...
'operationNumbers' => array(
'operationNumber' => $operationNumbersArray
)
During my testing and fiddling about, I had inadvertently removed another value that was mandatory. The API did not give warning of it's omission (sadly).
Here is the code I use:
$wsdl = 'https://your.api/path?wsdl';
$client = new SoapClient($wsdl);
$multipleSearchValues = [1, 2, 3, 4];
$queryData = ['yourFieldName' => $multipleSearchValues];
$results = $client->YourApiMethod($queryData);
print_r($results);
I'm having a problem getting a particular SOAP call to work -most of them work fine, but this one is giving me a headache.
The WSDL is http://fibre.venus.ispwebhost.com/FibreClassTest/colt.wsdl, and the request I am generating is:
$result = $soap->checkConnectivity(
array('checkConnectivityRequest' =>
array(
'requestType' => 'SITE',
'requestMode' => array(
'requestId' => date("Ymdhis"),
'siteAddress' => array(
'postalZipCode' => $this->postcode,
'connectivityType' => 'COLT FIBRE',
'bandwidth' => '2M',
),
)
)
)
);
However I'm getting a SOAP error back (which I believe means it's not even passing it to the web service), so not sure if I'm mis-reading the WSDL?
Thanks!
If you search in the content of http://fibre.venus.ispwebhost.com/FibreClassTest/colt.wsdl you will notice that there is not wsdl:operation named checkConnectivityRequest. The closest i saw was checkConnectivity so, try to replace checkConnectivityRequest with checkConnectivity and let me know.
Happy coding
My app uses CakePHP (2.2.5) to get data from a SOAP server. I put logging into the SoapSource.php connector to see the XML returned and to display the array returned:
$result = $this->client->__soapCall($method, array('parameters' => $tParams));
Logger::write('SOAP Last Response', $this->client->__getLastResponse(), 3, 'transaction');
Logger::write('SOAP Last Response Object', print_r($result, TRUE), 3, 'transaction');
But what I'm seeing in the log is that two (recently-added) fields present in the XML are missing from the array, specifically, the last two before the RPList (formatted here but otherwise verbatim):
<transactionResult>
<id>test</id>
<resultCode>0</resultCode>
<ReadScheduledRecordingsRsp>
<RecordingDefinitionList>
<RecordingDefinition>
<RDId>d8c16d8f-67c6-469a-83c3-d51d8f8859a9</RDId>
<Title>The Young and the Restless</Title>
<SeriesId>4422</SeriesId>
<KeepUntil>SpaceIsNeeded</KeepUntil>
<StartPadSeconds>0</StartPadSeconds>
<EndPadSeconds>0</EndPadSeconds>
<Frequency>EveryDay</Frequency>
<KeepAtMost>0</KeepAtMost>
<Priority>23</Priority>
<ShowType>Any</ShowType>
<AirtimeDomain>SpecificTime</AirtimeDomain>
<ChannelDomain>SpecificChannel</ChannelDomain>
<RPList>
...
Followed by:
ARRAY
(
[transactionResult] => stdClass Object
(
[id] => test
[resultCode] => 0
[ReadScheduledRecordingsRsp] => stdClass Object
(
[RecordingDefinitionList] => stdClass Object
(
[RecordingDefinition] => Array
(
[0] => stdClass Object
(
[RDId] => d8c16d8f-67c6-469a-83c3-d51d8f8859a9
[Title] => The Young and the Restless
[SeriesId] => 4422
[KeepUntil] => SpaceIsNeeded
[StartPadSeconds] => 0
[EndPadSeconds] => 0
[Frequency] => EveryDay
[KeepAtMost] => 0
[Priority] => 23
[ShowType] => Any
[RPList] => stdClass Object
(
...
I'm guessing I just forgot or didn't know to do something, but I don't know what. It's just very suspicious that the two fields that don't work are the two that were just added, but I can't find any place where the fields are enumerated.
The WSDL doesn't specify any fields at all, just that there will be a bunch of data inside a transactionResult.
In the connect call, the options likewise don't specify any fields.
It all worked fine until the back-end added those two fields, and it all still works fine, except that I can't see the 2 new fields in the object.
Any ideas?
It would be nice to see the XML for RPList. What version of PHP/libxml?
Have you actually validated the XML returned by __getLastResponse()?
It sounds to me like your using WSDL mode for the client but your WSDL file lacks precision. Try using a WSDL which actually describes the data being served up by the API.
Am I understanding that the $result object when dumped lists RPList but the value is not what you expect? If so you might be able to get away with adding the SOAP_SINGLE_ELEMENT_ARRAYS option to the clients constructor: new SoapClient($wsdl, array('features' => SOAP_SINGLE_ELEMENT_ARRAYS));. That's a long shot though. Need to see WSDL and full output from __getLastResponse().
Any errors? Try wrapping the call like so:
try {
$client = new SoapClient ('http://yoursite.com?WSDL',
array("trace" => 1,
"exceptions" => true,
"cache_wsdl" => WSDL_CACHE_NONE,
"features" => SOAP_SINGLE_ELEMENT_ARRAYS)
);
$result = $client->SomeMethod($data);
} catch (SoapFault $exception) {
var_dump($exception);
} catch (Exception $exception) {
var_dump($exception);
}
Short of fixing the WSDL/XML response your workaround seems like the best solution.