Spaces:
Paused
Paused
| import httpx | |
| from fastapi import APIRouter, HTTPException | |
| router = APIRouter() | |
| async def test_instagram_api(): | |
| """ | |
| Executa exatamente o mesmo cURL que funcionou no playground | |
| """ | |
| # URL exata do cURL que funcionou | |
| url = "https://graph.instagram.com/17841464166934843/media" | |
| # Parâmetros exatos do cURL | |
| params = { | |
| "domain": "INSTAGRAM", | |
| "image_url": "https://static01.nyt.com/images/2025/08/06/multimedia/06xp-mack-vkjp/06xp-mack-vkjp-mobileMasterAt3x.jpg", | |
| "access_token": "IGAAPf2LpaWcxBZAE1xTUdBeGFFTWFZAVTFMOHdBc21pTlJULXVaWVBXZAUNfZAUFKS1hMeENUV1FFRmpURjUxdnhZAeDN1cmVJLVFJeTZAuclFKVVRWNmltTHV1TE9pdXVWTVpzbFNqbGxVb1U1X3d0a3ozNDJWeFhvbHlZAckR0OXRlawZDZD" | |
| } | |
| try: | |
| async with httpx.AsyncClient(timeout=30.0) as client: | |
| print(f"🚀 Fazendo POST para: {url}") | |
| print(f"📋 Parâmetros: {params}") | |
| # Faz a requisição POST exatamente como o cURL | |
| response = await client.post(url, params=params) | |
| print(f"📊 Status Code: {response.status_code}") | |
| print(f"📄 Response: {response.text}") | |
| # Retorna a resposta completa | |
| return { | |
| "status_code": response.status_code, | |
| "response_text": response.text, | |
| "success": response.status_code == 200 | |
| } | |
| except Exception as e: | |
| print(f"❌ Erro: {str(e)}") | |
| raise HTTPException( | |
| status_code=500, | |
| detail=f"Erro: {str(e)}" | |
| ) |