salesforce-marketingcloud / fuelsdk-php Goto Github PK
View Code? Open in Web Editor NEWFuelSDK-PHP
License: MIT License
FuelSDK-PHP
License: MIT License
When trying to set up the following simple example I'm seeing an error:
require __DIR__ . '/vendor/autoload.php';
use FuelSdk\ET_Client;
use FuelSdk\ET_List;
$myclient = new ET_Client();
Fatal error: Uncaught Exception: Unable to validate App Keys(ClientID/ClientSecret) provided.: Unable to validate App Keys(ClientID/ClientSecret) provided, requestToken response: in /salesforce/vendor/salesforce-mc/fuel-sdk-php/src/ET_Client.php:255 Stack trace: #0 /salesforce/vendor/salesforce-mc/fuel-sdk-php/src/ET_Client.php(162): FuelSdk\ET_Client->refreshToken() #1 /salesforce/example.php(10): FuelSdk\ET_Client->__construct() #2 {main} thrown in /salesforce/vendor/salesforce-mc/fuel-sdk-php/src/ET_Client.php on line 255
Trying to debug this, if I add the following to ET_Client.php (line 234):
print_r($jsonRequest);
exit;
This shows that the config file is being included correctly and I can see my clientid and clientsecret.
Also uncommenting lines 239-240 returns blank:
echo "auth: \n";
print_r($authResponse);
So there's obviously some issue with the post request being sent.
Any ideas?
When I call ET_Asset::upload(), this error occured.
Please call stdClass as \stdClass()
at ET_Asset.php:49.
Caught exception: Unable to create import definition due to: ET_Post Object
(
[status] =>
[code] => 200
[message] =>
[results] => Array
(
[0] => stdClass Object
(
[StatusCode] => Error
[StatusMessage] => Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
[OrdinalID] => 0
[NewID] => 0
[Object] => stdClass Object
(
[PartnerKey] =>
[ObjectID] =>
[CustomerKey] => 591328f9bd7da
[Name] => SDK Generated Import 591328f9bd7da
[Description] => SDK Generated Import
[AllowErrors] => 1
[DestinationObject] => stdClass Object
(
[PartnerKey] =>
[ObjectID] => MGO_Country_Language
)
[FieldMappingType] => InferFromColumnHeadings
[FileSpec] => MGO_Country_Language.csv
[FileType] => CSV
[RetrieveFileTransferLocation] => stdClass Object
(
[PartnerKey] =>
[ObjectID] =>
[CustomerKey] => ExactTarget Enhanced FTP
)
[UpdateType] => Overwrite
)
)
)
[request_id] =>
[moreResults] =>
)
Hello there. First off, thank you for this library, it is working pretty well for us.
I'm trying to use this library to build integration for Drupal 8 but have ran into a slight stumbling block. Our client wants to use this system for signing website visitors up for newsletters. I've built out a system to map fields from the signup form to ET attributes, but I've hit a slight stumbling block - I can't tell what attribute is the email address? There are 175 attributes available using ET_ProfileAttribute::get() but none mention "email". Might there be another method I should use to obtain this?
Thank you.
Hey Michael,
I have been using your SDK and have found a few issues,
I have pushed commits to fix them on this branch: https://github.com/derpest/FuelSDK-PHP/commits/master - Please let me know what you think. Feel free to include my changes or you can address the issues yourself:
Thanks, I will continue pushing my fixes to my own branch
Hello there,
Great job with this SDK. I'm working with the Send Object and it's pulling everything I need, EXCEPT Total Sends and Total Opens. Is this an available property I can pull or do I have to do this a different way?
Hi,
In my local environment which is a bit more forgiving of errors (PHP 7), my code works. However in my server environment which has stricter error checking (HHVM) I get the following errors:
Please can you correct?
Warning: __soapcall() expects parameter 3 to be array, null given in lib/FuelSDK-PHP/ET_Client.php on line 695
Warning: First parameter must either be an object or the name of an existing class in /lib/FuelSDK-PHP/ET_Client.php on line 699
Notice: Cannot access property on non-object in /lib/FuelSDK-PHP/ET_Client.php on line 710
The Classic email tool will be deprecated in Jan 2019
https://help.salesforce.com/articleView?id=mc_overview_content_and_email_creation_tools.htm&type=5
Does this library still works with the Content Builder? @MichaelAllenClark @MichaelAllenClark
Unable to mock the client for unit testing purposes.
In function AddSubscriberToList on line 164 of ET_Client.php, shouldn't that be "$lists[]" (with the "s" at the end), rather than:
$list[] = array("ID" => $value);
?
You define $lists above that line:
$lists = array();
and then call $lists below that line:
$newSub->props = array("EmailAddress" => $emailAddress, "Lists" => $lists);
This will only apply to people using Mac for local development and I've only tested with 5.3.26:
$currentTime = new DateTime("now", new DateTimeZone( 'America/Los_Angeles' ));
Warning: SoapClient::SoapClient() [soapclient.soapclient]: I/O warning : failed to load external entity "ExactTargetWSDL.xml" in /Users/[username]/Apps/[appname]/ET_Client.php on line 61
Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from 'ExactTargetWSDL.xml' : failed to load external entity "ExactTargetWSDL.xml" in /Users/[username]/Apps/[appname]/ET_Client.php on line 61
While building Exact Target integration for a CMS I'm having problems getting the submission to work as intended.
This is a trimmed down example of the code being used, which was mirrored off the "Sample SOAP Envelope - Create a Subscriber with Attributes" example from the SOAP API docs page:
$subscriber = new ET_Subscriber();
$subscriber->authStub = $client;
$subscriber->props = [
'EmailAddress' => '[email protected]',
'Lists' => [
['ID' => $newsletter_id],
],
'Attributes' => [
[
'Name' => $last_name_attribute_id,
'Value' => 'My first name',
],
[
'Name' => $last_name_attribute_id,
'Value' => 'My last name',
],
],
];
$result = $subscriber->post();
?>
The $result->status equals TRUE for this request.
However, the submission does not show up on the subscribers list for the $newsletter_id newsletter.
Any idea why the above isn't working? Thanks.
Hi,
I've managed to push some data to a data extension on SFMC. It's supposed to trigger a journey but it does not.
I've been asked to pass the following params, and I am doing this in additional attributes. However I think they need to be there in root array when sending, is this an issue?
[contactKey] => SubscriberKey
[eventDefinitionkey] => ContactEvent-xxxx
While this looks eminently doable from the WSDL, I have not succeeded in inserting multiple rows into a data extension in one call. Every attempt to create the correct structure ends with a PHP error:
PHP Fatal error: SOAP-ERROR: Encoding: object has no 'Name' property
A method or example of doing this would be greatly appreciated, so I don't have to hammer your API with individual inserts (the number make the complexity of a data import via FTP not worthwhile)
on line 167 of ET_Client.php, $objWSSE->saveXML() is surrounded by utf8_encode
This is not needed, because this causes a double utf8 encode.
By removing the surrounding function and just setting it to:
$content = $objWSSE->saveXML();
This solved my issue of being able to send correct encoding to data extensions for multiple languages.
Hi,
I have been using sample-send.php to retrieve the tracking information for emails.I am unable to find the property for Total Clicks, Total Opens, Lists, Total Unsubscribes, Did not click, Did not open.
I would appreciate if you help me with this issue.
Regards,
Vijay Ayilavarapu
Experienced with "salesforce-mc/fuel-sdk-php": "1.1.0",
PHP Warning: Use of undefined constant MCRYPT_RIJNDAEL_128 - assumed 'MCRYPT_RIJNDAEL_128' (this will throw an Error in a future version of PHP) in /app/vendor/robrichards/xmlseclibs/src/XMLSecurityKey.php on line 136
PHP Warning: Use of undefined constant MCRYPT_MODE_CBC - assumed 'MCRYPT_MODE_CBC' (this will throw an Error in a future version of PHP) in /app/vendor/robrichards/xmlseclibs/src/XMLSecurityKey.php on line 137
PHP Warning: Use of undefined constant MCRYPT_RIJNDAEL_128 - assumed 'MCRYPT_RIJNDAEL_128' (this will throw an Error in a future version of PHP) in /app/vendor/robrichards/xmlseclibs/src/XMLSecurityKey.php on line 136
The above seems to be related to the dependency on ""name": "robrichards/wse-php" which is going to require the "robrichards/xmlseclibs": "^2.0"
I'd propose prefixing all files with namespace ExactTarget, such that ET_Client would become \ExactTarget\ET_Client. I can do the work if there's interest.
This should be reversed.
mcrypt_ functions are now depreciated and used in xmlseclibs.php
I'm getting this error:
PHP Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from '/tmp/ExactTargetWSDL.xml' : failed to load external entity "/tmp/ExactTargetWSDL.xml"
in myapp/Vendor/leowebx/fuelsdk-php/src/ET_Client.php on line 81
I don't want to use SOAP in the first place. How can I force Fuel to use the REST API?
Please replace all die() calls with exceptions so that errors can be handled in a user-friendly manner.
I am trying to add a row to a data extension, through a sub account.
I have specified the customerKey but this does not work. It works fine on the main account.
$postDRRow = new ET_DataExtension_Row();
$postDRRow->authStub = $this->getClient();
$postDRRow->props = $props;
$postDRRow->CustomerKey = $externalKey;
$response = $postDRRow->post();
What I get back is:
Unable to retrieve Data Extension using CustomerKey
The RefreshToken used by auth is needed when consuming a JWT for authentication however it becomes problematic when used by a server-to-server application that involved multi-threading.
xmlseclibs is now available via packagist / composer: https://packagist.org/search/?q=xmlseclib. I'd propose adding this as a dependency to allow for deprecating the xmlseclibs.php version available in this project. I'd be happy to do the work if there's buy-in.
Since 0.9 is out, can you issue another release so it's available at https://github.com/ExactTarget/FuelSDK-PHP/releases?
Cannot download wsdl due to SSL error. I'm on OSX 10.11.6, have cURL installed via homebrew (and it is up to date). The current way I am able to work around this error is by changing line 168 from:
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
to
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
JWT is now available via packagist / composer: https://packagist.org/search/?q=jwt. I'd propose adding this as a dependency to allow for deprecating the JWT.php version available in this project. I'd be happy to do the work if there's buy-in.
I'm new to SDK-PHP and stuck on installing it via composer. I am currently using WAMP server 3.1.0 for Windows 10 which has 3 versions of PHP included. As documentation said version 5.6.24 is required for SDK-PHP. So I tried available 5.6.31 and got this from composer
composer require salesforce-mc/fuel-sdk-php
Using version ^1.1 for salesforce-mc/fuel-sdk-php
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- doctrine/annotations v1.6.0 requires php ^7.1 -> your PHP version (5.6.31) does not satisfy that requirement.
- doctrine/annotations v1.6.0 requires php ^7.1 -> your PHP version (5.6.31) does not satisfy that requirement.
- doctrine/annotations v1.6.0 requires php ^7.1 -> your PHP version (5.6.31) does not satisfy that requirement.
- Installation request for doctrine/annotations (locked at v1.6.0) -> satisfiable by doctrine/annotations[v1.6.0].
Installation failed, reverting ./composer.json to its original content.
Then I changed PHP version to available 7.1.9 but that was not successful as well
composer require salesforce-mc/fuel-sdk-php
Using version ^1.1 for salesforce-mc/fuel-sdk-php
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for salesforce-mc/fuel-sdk-php dev-master -> satisfiable by salesforce-mc/fuel-sdk-php[dev-master].
- Can only install one of: salesforce-mc/fuel-sdk-php[v1.1.0, dev-master].
- Installation request for salesforce-mc/fuel-sdk-php ^1.1 -> satisfiable by salesforce-mc/fuel-sdk-php[v1.1.0].
Installation failed, reverting ./composer.json to its original content.
Would anyone be able to help resolving this issue?
We're storing the cached WSDL in the webroot. Is this an acceptable place to store it?
I'm only asking because I had a permissions issue storing the cache on my local machine. Of course in production, typically the webuser has all the necessary permissions.
Just thought I'd ask other's opinions.
Should the "sdl" on this line actually be wsdlLoc instead?
Seems that way since I don't see sdl declared anywhere else.
First, thank you for the work you have done with this library. I have a question about pagination. I am working specifically with data extensions and I see that the response shows that there is more data than the 2500 rows returned. I don't see a way to traverse through the entire data extension. Is this possible?
There is currently no way to limit the amount of time cURL takes to connect or transfer data. This can mean requests/scripts will run for minutes before timing out. Adding a configurable time out would allow these requests/scripts to fail quickly and be handled in a more user-friendly way.
The current config.php include isn't working, realpath("config.php") is returning false.
I have a question about the autoload require in ET_Client.php. What is the purpose of this line?
When trying to use the ET_Client class I get the following error:
(1/1) FatalErrorExceptionmain(): Failed opening required '/var/project/vendor/salesforce-mc/fuel-sdk-php/src/../vendor/autoload.php' (include_path='.:/usr/share/php')
If I comment the line out or change it to require __DIR__ . '/../../../autoload.php';
then I don't receive an error and everything seems to function normally.
I followed the installation instructions from the README to include this SDK in a custom Laravel 5.4 based tool that I'm working on. One change that I did make was that I added the SDK into the autoloader manually because otherwise it doesn't seem to get added.
"autoload": {
"classmap": [
"database",
"vendor/salesforce-mc/fuel-sdk-php/src"
],
"psr-4": {
"App\\": "app/"
}
},
How do I use the API to start an interaction? I already added the user to a data extension but no event is fired.
The data I was given was to post to /interaction?
HOST: https ://www. exacttargetapis.com
POST /interaction/v1/events
Content-Type: application/j son
Authorization: Bearer insertAccessTokenHere
{
“contactKey”: “SubscriberKey”,
“eventDefinitionkey” : “ContactEvent-xyz,
“data” :{
“SubscriberKey”: “insertCustomerldHere”,
“EmailAddress”: [email protected],
“Title” : “Mr”,
“FirstName” : “Sinon”,
“LastName” : “Stanley”,
“Product_Category” : “Steamers”,
Model_Type:“VX21”,
SMS_Opt_In : “True”,
Phone: “04234555”
}
}
According to this documentation:
Passing a value of 1 to a column expecting a boolean value should work to indicate TRUE. However, I've only been able to get this to work:
$dataextensionrow->props = array(
"Email" => $Email,
"XXXXX" => "true" // column expects boolean
);
While when I try this:
$dataextensionrow->props = array(
"Email" => $Email,
"XXXXX" => "1" // column expects boolean
);
Or this:
$dataextensionrow->props = array(
"Email" => $Email,
"XXXXX" => 1 // column expects boolean
);
I get the following error:
{ ["ValueError"]=> object(stdClass)#19 (3) { ["Name"]=> string(17) "BOOLEAN_COLUMN" ["ErrorCode"]=> int(2) ["ErrorMessage"]=> string(120) " String was not recognized as a valid Boolean.Couldn't store <1> in BOOLEAN_COLUMN Column. Expected type is Boolean." }
I can find a way around this, but it would be really great to be able to pass a 1, because the columns I'd like to pass essentially boolean values to are not actually all boolean columns. Some are set to accept a single text character instead (because these columns may potentially be changed to accept multiple characters later, and changing column type is not otherwise possible.) It would be great to not have to write a conditional to pass a different value (1 vs. TRUE) depending on the column's type. Has anyone else experienced/resolved this issue?
Hello, how i fix this bug?
I'm not sure how to modify mcrypt_module_get_algo_key_size()
When submitting an ET_Subscriber request, if the account has the SubscriberKey option enabled but it isn't submitted as a prop value then the API should throw an error, as right now it just returns a successful response though nothing is added to ExactTarget.
soap-wsse is now available via packagist / composer: https://packagist.org/search/?q=wse. I'd propose adding this as a dependency to allow for deprecating the soap-wsse.php version available in this project. I'd be happy to do the work if there's buy-in.
Did ET deprecate one of the API URLs used in refreshToken()?
$ curl https://auth.exacttargetapis.com/v1/requestToken?legacy=1
{"documentation":"https://code.docs.exacttarget.com/rest/errors/404","errorcode":404,"message":"Not Found"}
Currently, the ET client does not support proxy.
I forked this repository to get the SDK to more easily load into Symfony, and probably other frameworks such as Laravel. It's available on Packagist.
I am not a Symfony expert, but we already have a config.php in our web root and it is generated by Symfony and it cannot be changed, so this library was a non-starter to use as is.
I read a few of different PRs and incorporated some of them, and updated the README.md
A lot of work needs to be done on it to update the examples, but it's working fine in Symfony for us without config.php. In essence, I just pass everything I need to the constructor. I also pass along debug flag to the CUDUtils class and ET_Post making it easier to debug requests and responses.
I don't want to submit a PR yet because I believe it's a lot of breaking changes and unfinished but wanted to let you know about it and future Symfony and Laravel developers to try my branch. All feedback welcome.
The example for adding data extension rows says to use this:
$postDRRow->props = array("Key" => "PHPSDKTEST", "Value" => "ItWorks");
But the source code for ET_DataExtension_Row > post()
has this:
foreach ($this->props as $key => $value){
$fields[] = array("Name" => $key, "Value" => $value);
}
So it looks like, really, properties should be set like this:
$postDRRow->props = array(
"MyKey1" => "MyValue1",
"MyKey2" => "MyValue2"
);
Can you confirm?
The Fuel REST APIs all return hydrated responses on POST/PUT/PATCH operations.
It would be nice if the SDKs could reduce the invalidations required by developers by encapsulating this functionality.
Thoughts on this?
Triggered sends definitions need the ability to include the Client ID so that we can target definitions that exist within Business Units.
After chatting with @creatovisguru we have determined how to make a small change to add support for ClienID
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.