1

Is there any possibility to save the URL a specific domain/url refers to via PHP?

I need to convert this Facebook URL.

https://www.facebook.com/app_scoped_user_id/10xxxxxxxxx/

into the public URL one sees when you click on the name in Facebook.

Billal Begueradj
  • 20,717
  • 43
  • 112
  • 130
Julius S.
  • 664
  • 9
  • 21
  • That is the public one. – WizKid Oct 26 '16 at 20:07
  • Why would you need that? And no, you are not supposed to do that and it would be against Facebook ToS. Facebook introduced app-scoped user ids for a good reason - it's called privacy. – CBroe Oct 26 '16 at 20:26
  • `$o = $fb->get('/me', $token, null, ['id','name'])->getGraphUser();` `{$o['name']}` Basic, but maybe? – Pazuzu156 Oct 26 '16 at 20:27
  • I need that for implementing a user-protecting feature in a browser-extension. @Pazuzu156 Can you please explain how this is supposed to work, I won' try a code I do not understand. You are adding the user ID and Name after the facebook domain? I have at least 1 example where this does not create what I need so I do not have much hope that your code will help me. – Julius S. Oct 27 '16 at 08:48
  • `$fb` is a variable holding an instance of `Facebook\Facebook` and calling the `get()` method. `/me` gets the user who's "logged in" using the authorization token you get from logging in a Facebook user. `null` for eTags, and `['id','name']` is the array defining what I want to get from the call. `getGraphUser()` gets the result into the form of a Graph object. Refer to: https://developers.facebook.com/docs/php/howto/example_facebook_login for learning to authenticate a user and https://developers.facebook.com/docs/graph-api/reference to learn the Graph API endpoints to get user data – Pazuzu156 Oct 27 '16 at 15:31
  • @Pazuzu156 I don't think this code is generating the public link for a user profile. For example if you have a unique name, there is no ID in the url. – Julius S. Oct 28 '16 at 15:01
  • After reading the question more thoroughly, I'm guessing you already get the public URL from an API call. Correct me if I'm wrong. And you want to convert it to..say `https://facebook.com/USERNAME` correct? If that's the case: http://stackoverflow.com/a/23429721/1524676 It's probably best to stick with the given URL you get from the API call. You could remove `app_scoped_user_id` from the url with a simple call to `str_replace` – Pazuzu156 Oct 28 '16 at 19:00

0 Answers0