최근 검색
최근 검색 없음

Valentin Vina
가입한 날짜: 2024년 6월 11일
·
마지막 활동: 2025년 1월 13일
팔로잉
0
팔로워
0
총 활동 수
4
투표 수
0
플랜 수
2
활동 개요
배지
문서
게시물
커뮤니티 댓글
문서 댓글
활동 개요
님의 최근 활동 Valentin Vina
Valentin Vina님이 에 댓글을 입력함
Here's a sample using the Zendesk App Framework 2.0 with the ZAFClient
:
javascript
// Initialize the Zendesk App Framework client
const client = ZAFClient.init();
// Define the proxied endpoint relative to the proxy URL
const proxiedEndpoint = '/api/v1/auth/login';
// Define the request payload
const payload = {
username: 'user@example.com',
password: 'password123'
};
// Make the proxied POST request
client.request({
url: proxiedEndpoint,
type: 'POST',
contentType: 'application/json',
data: JSON.stringify(payload)
}).then(function(response) {
// Handle successful response
console.log('Login successful:', response);
}).catch(function(error) {
// Handle errors
console.error('Login failed:', error);
});
Node.js with Express
// server.js
const express = require('express');
const cors = require('cors');
const app = express();
// Middleware to parse JSON bodies
app.use(express.json());
// Define allowed origin (Zendesk proxy URL)
const allowedOrigin = 'https://subdomain.zendesk.com';
// Configure CORS
app.use(cors({
origin: allowedOrigin, // Allow only the Zendesk origin
methods: ['GET', 'POST', 'PUT', 'DELETE'],
allowedHeaders: ['Content-Type', 'Authorization']
}));
// Example login route
app.post('/api/v1/auth/login', (req, res) => {
const { username, password } = req.body;
// Implement your authentication logic here
if (username === 'user@example.com' && password === 'password123') {
res.json({ success: true, message: 'Login successful' });
} else {
res.status(401).json({ success: false, message: 'Invalid credentials' });
}
});
// Start the server
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log(`Server running on port ${PORT}`);
});
댓글 보기 · 2025년 1월 13일에 게시됨 · Valentin Vina
0
팔로워
0
투표 수
0
댓글
Valentin Vina님이 에 댓글을 입력함
use a function
import requests
def send_sms(ticket_id, phone_number, message):
# Step 1: Generate token
token_response = requests.post('https://example.com/generate-token', data={})
token = token_response.json().get('token')
# Step 2: Use the token to authenticate the SMS API
headers = {'Authorization': f'Bearer {token}'}
sms_response = requests.post(
'https://example.com/send-sms',
headers=headers,
data={'ticket_id': ticket_id, 'phone_number': phone_number, 'message': message}
)
return sms_response.json()
댓글 보기 · 2024년 6월 11일에 게시됨 · Valentin Vina
0
팔로워
0
투표 수
0
댓글