XF 2.1 German Umlauts and api

Robert9

Well-known member
Please tell me: What i have to do to send title and message with Umlauts to the api to make a thread without the wrong output /&%§("/&.
Is this possible at all?

Code:
                'Content-Type: application/x-www-form-urlencoded;',
                'XF-Api-User: 123',
                'XF-Api-Key: 123'

Code:
                $post = [
                    'node_id' => '123',
                    'title' => "äüßö",
                    'message' => "äüßö",
                ];
                $post = http_build_query($post);

                $furl = 'https://www.example.com/api/threads/';

                $ch = curl_init();
                curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
                curl_setopt($ch, CURLOPT_URL, $furl);
                curl_setopt($ch, CURLOPT_POST, true);
                curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                $response = curl_exec($ch);
                curl_close($ch);
 
I try now guzzle, but nothing happens

Code:
           try
            {
                $client = \XF::app()->http()->client();
                $response = $client->request('POST', 'https://www.example.com/api/threads/',
                    [
                        'headers' =>
                            [
                                'XF-Api-Key' => '123',
                                'XF-Api-User: 123',
                                'Content-Type' => 'application/json',
                            ],
                        'form_params' =>
                            [
                            'node_id' => '123',
                            'title' => $title,
                            'message' => $message,
                            'tags' => [''],
                            ],
                    ]
                );

            }
            catch (\GuzzleHttp\Exception\RequestException $e)
            {
                \XF::logException($e, false, "error: ");
                $continue = false;
            }

Any idea, what i miss, please?
 
Top Bottom