/** * Get the URL that the user should be sent to in order to * begin the OAuth2 redirect flow. * * @return string $url */ public function getOAuth2AuthorizationURI() { $this->requireClientIdAndRedirectURI(); $url = $this->treeState->getLink(GedcomxRel::OAUTH2_AUTHORIZE)->getHref(); $params = array('response_type' => 'code', 'redirect_uri' => $this->redirectURI, 'client_id' => $this->clientId); return $url . '?' . http_build_query($params); }
/** * Moves the current source description to the specified collection. * * @param CollectionState $collection * @param StateTransitionOption $options,... * @return FamilySearchSourceDescriptionState|null */ public function moveToCollection(CollectionState $collection, StateTransitionOption $options = null) { $link = $collection->getLink(Rel::SOURCE_DESCRIPTIONS); if ($link == null || $link->getHref() == null) { return null; } /** @var SourceDescription $me */ $me = $this->getSourceDescription(); if ($me == null || $me->getId() == null) { return null; } /** @var Gedcomx $gx */ $gx = new Gedcomx(); $sd = new SourceDescription(); $sd->setId($me->getId()); $gx->setSourceDescriptions(array($sd)); $request = $this->createAuthenticatedRequest('POST', $link->getHref(), FamilySearchRequest::getMediaTypes(), null, $gx->toJson()); return $this->stateFactory->createState('SourceDescriptionState', $this->client, $request, $this->passOptionsTo('invoke', array($request), func_get_args()), $this->accessToken); }