Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Joomla注册新用户-通过cUrl发送数据_Php_Api_Curl_Joomla - Fatal编程技术网

Php Joomla注册新用户-通过cUrl发送数据

Php Joomla注册新用户-通过cUrl发送数据,php,api,curl,joomla,Php,Api,Curl,Joomla,我有这个: $url = "http://xxxxxxxx"; $data = array ( userId => xxx, // authentication userId loginToken => 'xxxxxx', // authentication loginToken 'customerType' => 'Pe

我有这个:

$url = "http://xxxxxxxx";

$data = array (
userId                          =>      xxx, // authentication userId
loginToken                      =>      'xxxxxx', // authentication loginToken
'customerType'                  =>      'Person',
'firstName'                     =>      'Lukasz',
'lastName'                      =>      'Testowy',
'emails[0].email'               =>      'email@exaple.com',
'phones[0].phoneNumber'         =>      '0123456789',
'documentNo'                    =>      'ABC1234567',
'address.city'                  =>      'Warsaw',
'address.postalCode'            =>      '01-001',
'address.street'                =>      'Sobieskiego',
'note'                          =>      'some info'
);

$data_string = http_build_query($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch); 
当我将它保存为test.php并运行时,它运行得非常好。它将所有数据发送到$url

我需要把它连接到Joomla 3.x。当新用户注册时,这个脚本应该获取他的数据,如名字、姓氏等,并输入Lukas、Testowy等,然后将其发送到$url。怎么做?

好的,我们开始:

之后,在com_users/controllers/registration.php中添加了我的代码

} elseif ($return === 'useractivate')
        {
            $this->setMessage(JText::_('COM_USERS_REGISTRATION_COMPLETE_ACTIVATE'));
            $this->setRedirect(JRoute::_('index.php?option=com_users&view=registration&layout=complete', false));
而且它有效!在用户注册后,它通过cUrl发送样本数据。因此,问题是:
如何替换测试数据-Lukasz,Testowy,email@example.cometc关于正在注册的用户的数据?

您需要构建自己的组件来处理此问题,因为Joomla目前没有restful接口。可能的解决方案是编辑com_用户注册控制器?我不懂php,但我正在考虑在单击register?后将代码作为函数添加?@Lukasz我不能100%确定cURL请求的最终目标是什么。我的答案取决于你的最终目标是什么。例如,您是否试图将这些字段添加到Joomla中的核心用户注册和配置文件中?因为如果使用用户插件的话,这其实很容易做到。我不太懂php,所以我将用easy语言进行讨论。我的目标是:用户正在注册,单击register并在joomla中注册,用户的数据将放入我的脚本并运行。我想没什么了:我的脚本只是在一些web应用程序上创建用户,并且单独工作很好。我需要把它连接到joomla注册。