{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-@l10n/ja/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"クラウドフォンの例","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"クラウドフォンの例","__idx":0},"children":["クラウドフォンの例"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["オープン API を使用したクラウド電話管理の完全な実例。"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["ベース URL"]},": ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["https://api.morelogin.com"]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"完全なワークフロー-認証--作成--アプリのインストール--adb","__idx":1},"children":["完全なワークフロー: 認証 → 作成 → アプリのインストール → ADB"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"カールする","__idx":2},"children":["カールする"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"# 1. Get access token\nTOKEN=$(curl -s -X POST https://api.morelogin.com/oauth2/token \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"client_id\": \"YOUR_API_ID\",\n    \"client_secret\": \"YOUR_API_KEY\",\n    \"grant_type\": \"client_credentials\"\n  }' | jq -r '.data.access_token')\n\necho \"Token: $TOKEN\"\n\n# 2. Create a cloud phone\ncurl -X POST https://api.morelogin.com/cloudphone/create \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -d '{\n    \"name\": \"my-cloud-phone\",\n    \"areaId\": 1,\n    \"groupId\": \"your-group-id\"\n  }'\n\n# 3. Start the cloud phone\ncurl -X POST https://api.morelogin.com/cloudphone/start \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -d '{\"ids\": [\"CLOUD_PHONE_ID\"]}'\n\n# 4. Install an app\ncurl -X POST https://api.morelogin.com/cloudphone/app/install \\\n  -H \"Content-Type: application/json\" \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -d '{\n    \"id\": CLOUD_PHONE_ID,\n    \"packageName\": \"com.example.app\",\n    \"versionCode\": 1\n  }'\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"python-リクエスト","__idx":3},"children":["Python (リクエスト)"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"import requests\n\nBASE = \"https://api.morelogin.com\"\nAPI_ID = \"YOUR_API_ID\"\nAPI_KEY = \"YOUR_API_KEY\"\n\n# 1. Get access token\nresp = requests.post(f\"{BASE}/oauth2/token\", json={\n    \"client_id\": API_ID,\n    \"client_secret\": API_KEY,\n    \"grant_type\": \"client_credentials\"\n})\ntoken = resp.json()[\"data\"][\"access_token\"]\nheaders = {\"Authorization\": f\"Bearer {token}\"}\nprint(f\"Token acquired (expires in {resp.json()['data']['expires_in']}s)\")\n\n# 2. Create a cloud phone\nresp = requests.post(f\"{BASE}/cloudphone/create\", headers=headers, json={\n    \"name\": \"automation-phone\",\n    \"areaId\": 1,\n    \"groupId\": \"your-group-id\"\n})\nphone_id = resp.json()[\"data\"][\"id\"]\nprint(f\"Created cloud phone: {phone_id}\")\n\n# 3. Start the cloud phone\nresp = requests.post(f\"{BASE}/cloudphone/start\", headers=headers, json={\n    \"ids\": [str(phone_id)]\n})\nprint(f\"Start result: {resp.json()['code']}\")\n\n# 4. Install app\nresp = requests.post(f\"{BASE}/cloudphone/app/install\", headers=headers, json={\n    \"id\": phone_id,\n    \"packageName\": \"com.example.app\",\n    \"versionCode\": 1\n})\nprint(f\"App install: {resp.json()['code']}\")\n\n# 5. Enable ADB\nresp = requests.post(f\"{BASE}/cloudphone/enableAdb\", headers=headers, json={\n    \"id\": phone_id\n})\nadb_info = resp.json()[\"data\"]\nprint(f\"ADB enabled - connect with: adb connect {adb_info.get('host')}:{adb_info.get('port')}\")\n\n# 6. Stop cloud phone when done\nresp = requests.post(f\"{BASE}/cloudphone/stop\", headers=headers, json={\n    \"ids\": [str(phone_id)]\n})\nprint(\"Cloud phone stopped.\")\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"nodejs-axios","__idx":4},"children":["Node.js (axios)"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"const axios = require('axios');\n\nconst BASE = 'https://api.morelogin.com';\nconst API_ID = 'YOUR_API_ID';\nconst API_KEY = 'YOUR_API_KEY';\n\nasync function main() {\n  // 1. Get access token\n  const authResp = await axios.post(`${BASE}/oauth2/token`, {\n    client_id: API_ID,\n    client_secret: API_KEY,\n    grant_type: 'client_credentials'\n  });\n  const token = authResp.data.data.access_token;\n  const headers = { Authorization: `Bearer ${token}` };\n  console.log('Token acquired');\n\n  // 2. Create a cloud phone\n  const createResp = await axios.post(`${BASE}/cloudphone/create`,\n    { name: 'automation-phone', areaId: 1 },\n    { headers }\n  );\n  const phoneId = createResp.data.data.id;\n  console.log(`Created cloud phone: ${phoneId}`);\n\n  // 3. Start cloud phone\n  await axios.post(`${BASE}/cloudphone/start`,\n    { ids: [String(phoneId)] },\n    { headers }\n  );\n  console.log('Cloud phone started');\n\n  // 4. Install app\n  await axios.post(`${BASE}/cloudphone/app/install`,\n    { id: phoneId, packageName: 'com.example.app', versionCode: 1 },\n    { headers }\n  );\n  console.log('App installation initiated');\n\n  // 5. Enable ADB\n  const adbResp = await axios.post(`${BASE}/cloudphone/enableAdb`,\n    { id: phoneId },\n    { headers }\n  );\n  console.log('ADB enabled:', adbResp.data.data);\n\n  // 6. Stop when done\n  await axios.post(`${BASE}/cloudphone/stop`,\n    { ids: [String(phoneId)] },\n    { headers }\n  );\n  console.log('Cloud phone stopped');\n}\n\nmain().catch(console.error);\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"ファイルのアップロード例-python","__idx":5},"children":["ファイルのアップロード例 (Python)"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"import requests\n\nBASE = \"https://api.morelogin.com\"\nheaders = {\"Authorization\": \"Bearer YOUR_TOKEN\"}\n\nphone_id = 1234567890\n\n# 1. Get presigned upload URL\nresp = requests.post(f\"{BASE}/cloudphone/uploadUrl\", headers=headers, json={\n    \"id\": phone_id,\n    \"fileName\": \"config.json\"\n})\nupload_url = resp.json()[\"data\"][\"presignedUrl\"]\n\n# 2. Upload file to presigned URL\nwith open(\"config.json\", \"rb\") as f:\n    requests.put(upload_url, data=f)\n\n# 3. Trigger file upload to cloud phone\nresp = requests.post(f\"{BASE}/cloudphone/uploadFile\", headers=headers, json={\n    \"id\": str(phone_id),\n    \"url\": upload_url,\n    \"uploadDest\": \"/Download\"\n})\nfile_id = resp.json()[\"data\"][\"fileId\"]\n\n# 4. Check upload result\nresp = requests.post(f\"{BASE}/cloudphone/uploadFileResult\", headers=headers, json={\n    \"id\": str(phone_id),\n    \"fileId\": file_id\n})\nprint(f\"Upload status: {resp.json()['data']['status']}\")  # 1 = success\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"完全な-python-sdk-サンプル","__idx":6},"children":["完全な Python SDK サンプル"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["上記のスニペットは個別の API 呼び出しを示しています。",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["自動トークン管理、コネクションプーリング、完全なデバイスライフサイクル操作"]},"を備えた",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["本番環境対応の Python クライアントクラス"]},"については、GitHub の完全なサンプルを参照してください："]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["📦 ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/MoreLoginBrowser/MoreLogin-API-Demos/blob/main/MoreLogin-Python/cloud_phone/cloud_phone_open_api_demo.py"},"children":["GitHub — cloud_phone_open_api_demo.py"]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["含まれる機能："]}]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"機能"},"children":["機能"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"説明"},"children":["説明"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["自動トークン更新"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["有効期限の 60 秒前にアクセストークンを自動的に取得・更新"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["コネクションプーリング"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["高スループットシナリオに対応した設定可能なプールサイズの ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["requests.Session"]}," を使用"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["デバイス管理"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["デバイス一覧、デバイス情報取得、Android ID による検索"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["電源管理"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["クラウドフォンの電源オン/オフ（オプションのプロキシ割り当て対応）"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["アプリ管理"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["アプリのインストール、起動、停止、再起動、アンインストール"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["ファイル管理"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["クラウドフォンとのファイルのアップロード・ダウンロード"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["プロキシとグループ"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["オープン API を通じたプロキシとグループの管理"]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["クイック使用法："]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"from cloud_phone_open_api_demo import MoreLoginCloudPhone\n\nclient = MoreLoginCloudPhone(app_id=\"YOUR_APP_ID\", api_key=\"YOUR_API_KEY\")\n\n# すべてのクラウドフォンを一覧表示\ndevices = client.list_devices()\nprint(devices)\n\n# デバイス情報を取得\ninfo = client.get_device_info(phone_id=1234567890)\nprint(info)\n\n# クラウドフォンの電源をオン\nclient.power_on(phone_id=1234567890)\n","lang":"python"},"children":[]}]},"headings":[{"value":"クラウドフォンの例","id":"クラウドフォンの例","depth":1},{"value":"完全なワークフロー: 認証 → 作成 → アプリのインストール → ADB","id":"完全なワークフロー-認証--作成--アプリのインストール--adb","depth":2},{"value":"カールする","id":"カールする","depth":3},{"value":"Python (リクエスト)","id":"python-リクエスト","depth":3},{"value":"Node.js (axios)","id":"nodejs-axios","depth":3},{"value":"ファイルのアップロード例 (Python)","id":"ファイルのアップロード例-python","depth":2},{"value":"完全な Python SDK サンプル","id":"完全な-python-sdk-サンプル","depth":2}],"frontmatter":{"seo":{"title":"クラウドフォンの例"}},"lastModified":"2026-06-17T03:35:58.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/ja/api-reference/examples/cloudphone-examples","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}