I am working on Twitter Application, in it I get user tweets and if user share URL in it then it open in WebView.
But problem is that Twitter returns hyperlink like, http://t.co/eleekj4F.
I want to convert it in its original form as I have posted like http://www.abcd.com/testing.html
Twitter Developer See other similar threads also in the same forum.
Use expanded_url instead of url from returned entities.
I know there are some applications online that let you retrive the original url, you could maybe parse the response from them.
http://www.makeuseof.com/dir/untiny-extract-original-link-short-url/
I think you could also do it, by doing a http request to the short url and see what adress you are redirected to.
Related
I have a photo sharing web application and one of my requirements is to add a way to quickly share a photo to Facebook.
I have looked at several ways to do this, and the one I like the most is to get an OAuth access token and redirect back to my site. Once they select the image they want to share, I then launch the share dialog window in an iframe:
https://www.facebook.com/dialog/share?app_id=[MY_APP_ID]&display=iframe&href=https%3A%2F%2Fexample.com%2Fsomepic.jpg&access_token=[TOKEN_FROM_OAUTH]
This all works fine, except it shares a LINK to the picture and doesn't actually upload the image and store on Facebook.
So, my next thought was to use my access_token and create an upload session. So, I first create the session at this endpoint:
POST https://graph.facebook.com/app/uploads?access_token=[MY_OAUTH_ACCESS_TOKEN]&file_type=image/jpeg
That returns a session id for me as I expect. I then upload the file through this endpoint:
POST https://graph.facebook.com/[SESSION_ID_FROM_PREVIOUS_STEP]?is_reusable=true&file_length=[BYTES_OF_IMAGE]&data=[IMAGE_DATA_BYTES]
The above all seems to work, and it returns me a "File Handle". Something that looks like this:
4::aW1hZ2UvanBlZw==:ARaQWknagoLiMi1rE4wzsPLLKoWuwj0hpx8Wyv9p7VX0cMvZ0c5qTESqW1qyeb-ejM-BsoIaHcy1DfkEGZhAAaN-7ShSffoRDEZn1kK1IJ00bA:e:1632539894:100624633370919:533575686:ARZVnrjRFvfvQcEYvbw
Now to the point of my question. Is it at all possible to somehow pass the above file handle to the dialog share iframe as opposed to passing it a URL? Something like this:
https://www.facebook.com/dialog/share?app_id=[MY_APP_ID]&display=iframe&attachment_id=4::aW1hZ2UvanBlZw==:ARaQWknagoLiMi1rE4wzsPLLKoWuwj0hpx8Wyv9p7VX0cMvZ0c5qTESqW1qyeb-ejM-BsoIaHcy1DfkEGZhAAaN-7ShSffoRDEZn1kK1IJ00bA:e:1632539894:100624633370919:533575686:ARZVnrjRFvfvQcEYvbw&access_token=[TOKEN_FROM_OAUTH]
I know that attachment_id doesn't work, but is there another way to do this?
It may not be possible, but would make it a cleaner solution that having a link to the images, which may end up changing...
Thanks!
My thoughts so far:
To Post a image with text to a Facebook Page i use this endpoint 'https://graph.facebook.com/{page-id}/photos?url={image-url}&message=your message'
This works fine but to get the {image-url} the image needs to be uploaded beforehand.
I would like to know URL which is link to post to facebook. On Twitter, I can use "http://twitter.com/intent/tweet?text=" to tweet. Although I was trying to search for one, I could not find it.
http://www.facebook.com/sharer.php?s=100&p[title]=YOURTITLE&p[url]=http://www.yourdomain.com&p[summary]=shortandsweetok&p[images][0]=http://www.image.to/appearwithlinkaftersharing.jpg
This works but the images might not show properly in some cases
In twitter it's possible by doing:
https://twitter.com/intent/tweet?text=THIS IS MY MESSAGE IT NEEDS ENCODING
Then it will bring up twitter with that message, and let you choose whether or not you want to tweet it.
I was wondering if there's a similar way with facebook posting a message through a link?
Thanks!
-Tim
Yes - and you don't need an app registered to do so! The only down side, is that you have to include a URL.
The query is simply:
https://www.facebook.com/sharer/sharer.php?u=<URL>&t=<text>
For example - https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fshkspr.mobi%2Fblog%2F&t=Check%20out%20this%20cool%20blog
Both the URL and the text will have to be URL encoded. As I said, it won't work without a URL.
Yes, you have the Feed Dialog that does the same. But of course you must have an app registered on http://developers.faceboof.com/apps.
URL Redirection:
https://www.facebook.com/dialog/feed?
app_id=145634995501895
&display=popup
&caption=An%20example%20caption
&link=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2Fdialogs%2F
&redirect_uri=https://developers.facebook.com/tools/explorer
(replace app_id and redirect_uri with that of yours)
For the list of available parameters, check here
I would like to add a Facebook Like button inside my software.
I know how to programmatically do the actual liking process,
but how do I check and see if a person actually has liked my page?
Edit: I'm guessing that my software also has got to communicate with an actual Facebook App
that I have to develop, and not Only with a regular facebook html source?
Have you considered dropping a TWebControl on your Delphi form, assigning a simple HTML document string to it that contains the markup needed for a Facebook like button and making it just large enough to display your facebook like button content?
The like count and user liked state would be handled automatically by the javascript dynamically loaded into the html page. The javascript written by Facebook.
Seems like a full-functionality, least-effort approach worth considering.
I don't have Facebook to test this, but try to use what is described in this blog post; try to use the following HTTP GET request and in the response (after you parse it), find the user you're looking for:
https://graph.facebook.com/me/likes/PAGE_ID&access_token=ACCESS_TOKEN
Where PAGE_ID should be your page ID and ACCESS_TOKEN your access token.
For a simple GET request you can use e.g. this code.
How can I get a link to a Facebook or Twitter avatar by username?
For Facebook the image is publically availible and can be seen at: http://graph.facebook.com/username/picture
For example, here is mine: http://graph.facebook.com/totten/picture
You will notice that the url above actually gets forwarded to another caching url. Don't save the long url (http://profile.ak.fbcdn.net/....) save the short http://graph.facebook.com/ one. The other, longer url, could change and break.
If you want to display that url in a web page you just need to do the following:
<img src="//graph.facebook.com/totten/picture" />
Which gets you: http://graph.facebook.com/totten/picture
Thats it, no complicated API or authentication is needed.
For twitter you need to use the api: http://apiwiki.twitter.com/w/page/22554755/Twitter-REST-API-Method:-users%C2%A0show
you have to use facebook's graph API to get profile pictures. You'll have to register your app with facebook to get an API key, and then you can access most of the information on a given user's profile.check out their developer page to see some examples
Twitter just changed the way they handle API call. Looks like you'll have to register your app with them as well to get access to the avatars. I haven't used the twitter API since they changed it, so i'm not a sure about what goes on, but check out the docs page to read up on what you'd have to do.
hope this helps!
Some programming paradigms (Razor in ASP.NET or ASP.NET MVC 3, for example) have their own helpers to work with social media. If the paradigm you are programming in does not have helpers, you will have to access the FaceBook and/or Twitter APIs and use them to get the "avatar".
I have not played with Facebook, but the Twitter avatar link is provided on the user's profile, when you get it.
With regards twitter, I was able to get mine by visiting my profile page:
https://twitter.com/<USERNAME>
From there, you locate the <a> tag with the class ProfileAvatar-image and extract the href attribute. I was able to use that link on a separate site to import my avatar from Twitter.
I did all this manually, but it would be relatively easy to set up a script that used the username to request the profile page and isolate that link.