001/* 002 * Copyright (c) 2010-2026 Mark Allen, Norbert Bartels. 003 * 004 * Permission is hereby granted, free of charge, to any person obtaining a copy 005 * of this software and associated documentation files (the "Software"), to deal 006 * in the Software without restriction, including without limitation the rights 007 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 008 * copies of the Software, and to permit persons to whom the Software is 009 * furnished to do so, subject to the following conditions: 010 * 011 * The above copyright notice and this permission notice shall be included in 012 * all copies or substantial portions of the Software. 013 * 014 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 015 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 016 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 017 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 018 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 019 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 020 * THE SOFTWARE. 021 */ 022package com.restfb; 023 024/** 025 * Interface for accessing the Facebook Endpoints. 026 * <p> 027 * Facebook provides several endpoints that are used for working with the Graph API and working with Facebook in 028 * general. This interface provides methods to access the different urls. 029 * <p> 030 * The default implementation is {@link FacebookEndpoints}. That class provides the access to Facebook and should be 031 * used in productive environments. 032 * <p> 033 * This interface provides some fields with the default URLs so custom implementation can directly use these or modify 034 * the url or provide a completely custom one. This is possible without extending our default implementation. 035 * <p> 036 * In tests, a custom implementation can be used to mock the Facebook service. The implementing class only needs to 037 * provide urls to the mock service and the custom class is set in the {@link DefaultFacebookClient}. 038 */ 039public interface FacebookEndpoints { 040 041 /** 042 * returns the Facebook URL 043 * 044 * @return the Facebook URL 045 */ 046 default String getFacebookEndpoint() { 047 return Endpoint.SERVER.getUrl(); 048 } 049 050 /** 051 * returns the Facebook Graph API endpoint URL 052 * 053 * @return the Facebook Graph API endpoint URL 054 */ 055 default String getGraphEndpoint() { 056 return Endpoint.GRAPH.getUrl(); 057 } 058 059 /** 060 * returns the Facebook Graph API Video endpoint URL 061 * 062 * @return the Facebook Graph API Video endpoint URL 063 * @deprecated the Graph Video endpoint is deprecated; video uploads use the Graph API endpoint instead. 064 */ 065 @Deprecated 066 default String getGraphVideoEndpoint() { 067 return Endpoint.GRAPH_VIDEO.getUrl(); 068 } 069 070 /** 071 * returns the Facebook Reel Upload endpoint URL 072 * 073 * @return the Facebook Reel Upload endpoint URL 074 */ 075 default String getReelUploadEndpoint() { 076 return Endpoint.RUPLOAD.getUrl(); 077 } 078 079 default String getInstagramEndpoint() { 080 return Endpoint.INSTAGRAM_GRAPH.getUrl(); 081 } 082 083 default String getInstagramApiEndpoint() { 084 return Endpoint.INSTAGRAM_API.getUrl(); 085 } 086 087 default String getInstagramOAuthEndpoint() { 088 return Endpoint.INSTAGRAM_OAUTH.getUrl(); 089 } 090 091 default String getThreadsBaseEndpoint() { 092 return Endpoint.THREADS_OAUTH.getUrl(); 093 } 094 095 default String getThreadsApiEndpoint() { 096 return Endpoint.THREADS_GRAPH.getUrl(); 097 } 098 099 enum Endpoint { 100 /** 101 * General Facebook endpoint URL. 102 */ 103 SERVER("https://www.facebook.com"), 104 105 /** 106 * Graph API endpoint URL. 107 */ 108 GRAPH("https://graph.facebook.com"), 109 110 /** 111 * Legacy Video Upload API endpoint URL. 112 */ 113 @Deprecated 114 GRAPH_VIDEO("https://graph-video.facebook.com"), 115 116 /** 117 * Reels Upload endpoint URL. 118 */ 119 RUPLOAD("https://rupload.facebook.com/video-upload"), 120 121 /** 122 * Instagram Graph API endpoint URL. 123 */ 124 INSTAGRAM_GRAPH("https://graph.instagram.com"), 125 126 /** 127 * Instagram API endpoint URL. 128 */ 129 INSTAGRAM_API("https://api.instagram.com"), 130 131 /** 132 * Instagram website URL. 133 */ 134 INSTAGRAM_OAUTH("https://www.instagram.com"), 135 136 /** 137 * Threads OAuth endpoint URL. 138 */ 139 THREADS_OAUTH("https://www.threads.net"), 140 141 /** 142 * Threads Graph API endpoint URL. 143 */ 144 THREADS_GRAPH("https://graph.threads.net"); 145 146 private final String url; 147 148 Endpoint(String url) { 149 this.url = url; 150 } 151 152 public String getUrl() { 153 return url; 154 } 155 } 156}