I'm using https://github.com/AlexaCRM/php-crm-toolkit to send data from a form to an entity in CRM.
With normal fields it's okay but when I want to add 'new_produit_demande' it's gives error because that field is assigned to another entity ('new_produituic') and ('contact')
Any suggestions?
This is some code and it's not working.
<?php
require 'autoload.php' ;
use AlexaCRM\CRMToolkit\Client as OrganizationService;
use AlexaCRM\CRMToolkit\Settings;
$options = [
'serverUrl' => 'https://xxxxx',
'username' => 'xxxx',
'password' => 'xxxx',
'authMode' => 'xxx',
];
$serviceSettings = new Settings( $options );
$service = new OrganizationService( $serviceSettings );
$guid = 'd5bac140-b68b-e911-80cc-005056aa3849';
$contact = $service->entity('contact');
$contact->firstname='product1';
$contact->new_produit_demande = new EntityReference('new_produituic',$guid);
$contactId = $contact->create();
The error:
Fatal error: Class 'EntityReference' not found in C:\xampp\htdocs\ccr\test.php on line 29
You have to include the below namespace:
use AlexaCRM\CRMToolkit\Entity\EntityReference;
Related
I'm using a third-party extension in Symfony to connect to SSRS: https://github.com/ChartBlocks/php-ssrs
I need to keep my SSRS datasource as "prompt for credentials" since we are also using another solution that requires that, but I'm unsure how to set the DataSourceCredentials in my solution. I get the error: System.Web.Services.Protocols.SoapException: One or more data source credentials required to run the report have not been specified.
Here's my code in my controller:
$options = [
'username' => $this->getParameter('ssrs_user'),
'password' => $this->getParameter('ssrs_password')
];
$ssrs = new SSRS\Report($this->getParameter('ssrs_server'), $options);
$result = $ssrs->loadReport($this->getParameter('ssrs_base').'/'.$request->get('report'));
$ssrs->setSessionId($result->executionInfo->ExecutionID);
$parameters = json_decode($request->get('parameters'),true);
$ssrs->setExecutionParameters(new SSRS\Object\ExecutionParameters($parameters));
$output = $ssrs->render('HTML4.0'); // PDF | XML | CSV | HTML4.0 | Excel
return $output;
Anyone know what I need to add to pass the DataSourceCredentials?
Found an answer by creating my own method in the Report.php file, until it's updated in the core:
public function setDataSourceCredentials($datasource,$username,$password) {
$this->checkSessionId();
$options = array(
'Credentials' => array(
'DataSourceCredentials' => array(
'DataSourceName' => $datasource,
'UserName' => $username,
'Password' => $password
)
)
);
$result = $this->getSoapExecution()->SetExecutionCredentials($options);
return new ExecutionInfo($result);
}
I call this in my controller before rendering the report:
$ssrs->setExecutionParameters(new SSRS\Object\ExecutionParameters($parameters));
$ssrs->setDataSourceCredentials($this->getParameter('ssrs_datasource'),$this->getParameter('ssrs_sql_user'),$this->getParameter('ssrs_sql_password'));
I am currently trying to figure out why I get this error:
FatalThrowableError: Class 'App\Http\Controllers\Object' not found in Operators.php line 23
This is the Operators.php controller from where the error is coming from:
public function getOperatorData()
{
$api = new Client([
'base_uri' => 'https://www.space-track.org',
'cookies' => true,
]); $api->post('ajaxauth/login', [
'form_params' => [
'identity' => '#',
'password' => '#',
],
]);
$response = $api->get('basicspacedata/query/class/satcat/orderby/INTLDES%20desc/limit/1/metadata/false');
$mydata = json_decode($response->getBody()->getContents());
$object = new Object();
$object->intldes = $mydata->INTLDES;
$object->satname = $mydata->SATNAME;
$object->save();
return view('pages/satellite-database', compact('object'));
}
The specific line from where the error comes from is:
$object = new Object();
The line shown above should be creating a new model for querying`in a blade file later on.
I am usually able to solve these (either I forgot the 'use' or something), but I have been unable to solve this error.
Turns out the problem lay in the $mydata = json_decode($response->getBody()->getContents());.
Once I changed $mydata to return, I managed to make the JSON format properly and get the $object array to work.
I am working with mailgun php sdk. But I am getting error (Invalid resource type: array) when I try to update a user from mailing list. My Code is bellow.
$client = new \Http\Adapter\Guzzle6\Client();
$mgClient = new \Mailgun\Mailgun('YOUR_API_KEY', $client);
$listAddress = 'LIST#YOUR_DOMAIN_NAME';
$memberAddress = 'bob#example.com';
# Issue the call to the client.
$result = $mgClient->put("lists/$listAddress/members/$memberAddress", array(
'subscribed' => 'no',
'name' => 'Foo Bar'
));
First, make sure you are using the last version of php-http/guzzle6-adapter, then try the following:
$client = \Http\Adapter\Guzzle6\Client::createWithConfig([
'headers' => [
'Content-Type' => 'application/x-www-form-urlencoded'
]
]);
$mgClient = new \Mailgun\Mailgun('YOUR_API_KEY', $client);
$listAddress = 'LIST#YOUR_DOMAIN_NAME';
$memberAddress = 'bob#example.com';
# Issue the call to the client.
$result = $mgClient->put("lists/$listAddress/members/$memberAddress", http_build_query([
'subscribed' => 'no',
'name' => 'Foo Bar'
]));
I have been trying to add members to my google apps group. I am trying with following code but it raises error. Don't know what is doing wrong.
include_once 'api-client/autoload.php';
$clientId = 'xxxxxxxxxxxxxxxxx.apps.googleusercontent.com';
$serviceAccountName = 'xxxxxxxxxxxxxxxxxxx#developer.gserviceaccount.com';
$delegatedAdmin = 'superadmin#domain.com';
$keyFile = 'mw-gxxxxxxxx.p12';
$appName = 'Example App';
$scopes = array(
'https://www.googleapis.com/auth/admin.directory.group'
);
$creds = new Google_Auth_AssertionCredentials(
$serviceAccountName,
$scopes,
file_get_contents($keyFile)
);
$creds->sub = $delegatedAdmin;
$client = new Google_Client();
$client->setApplicationName($appName);
$client->setClientId($clientId);
$client->setAssertionCredentials($creds);
$dir = new Google_Service_Directory($client);
$member = new Google_Service_Directory_Member(array('name#domain.com',
'kind' => 'admin#directory#member',
'role' => 'MEMBER',
'type' => 'USER'));
$list = $dir->members->insert('01tuee7433xxxxx', $member);
The error:
Fatal error: Uncaught exception 'Google_Service_Exception' with message
'Error calling POST https://www.googleapis.com/admin/directory/v1/groups/01tuee7433v8xwz/members: (400) Missing required field: memberKey'
You should add 'email' in the $member object, as it is a required field for the POST request to add a new member in the specified group.
$member = new Google_Service_Directory_Member(array('email' => 'name#domain.com',
'kind' => 'admin#directory#member',
'role' => 'MEMBER',
'type' => 'USER'));
You can refer to this documentation.
Hope that helps!
We want to import all our database into one of your lists. We use php. The code is:
$api_key = "dXXXXXXX7eX276XXXXXXXX490";
$list_id = "7XXXb0XXXe";
$Mailchimp = new Mailchimp($api_key);
$Mailchimp_Lists = new Mailchimp_Lists($Mailchimp);
$batch = array();
$batch[] = array('email' => array(
'email' => 'xxxgmail.com',
"euid" => "xxx#gmail.com",
"leid" => "xxx#gmail.com"
),
'merge_vars' => array('FNAME' => 'XXX'));
$subscriber = $Mailchimp_Lists->batchSubscribe($list_id, $batch, false, true, true);
But I get an error
Mailchimp_User_DoesNotExist
Could not find user record with id
I tried many times, removed uuid and leid but no success. What is wrong? Thank you!
The API key used by me was incorrect.