Generating preview of posts on social media - php

This could be a fairly open question but I need to make posts to various social media websites such as facebook, twitter, linkedin, google etc. Now keep in mind that this is a true post and not just a share - in other words, I have stored the user credentials via OAuth and am going to make a formatted post to their wall, feed etc.
Question: Is there someway I can generate an exact or very close preview of the post on various social media? For example, can I show the user what their post will look like on facebook or google before they make the post?
I searched around the internet and all I could find is information about sharing.
I am using PHP, Javascript

You can read the Open Graph tags of the URL with JavaScript or PHP, for example: https://github.com/fiann/jquery.ogp
You can put the tags together for a view, but you can never be 100% sure how it will look like, especially on Facebook.

Related

Access Shares from a Company on LinkedIn via PHP from Wordpress

I am trying to retrieve the shares of a company on linkedIn (basically just read the stream, as is easily possible on twitter) to display them on a Wordpress website in a custom HTML/CSS styling, so I only need the data. This should happen just in the backend, so no user interaction (as login etc.) should be necessary.[The end result is simply a slider that aggregates the latest social media posts, like twitter, facebook & linkedin. Works for Twitter & FB so far.]
After many hours of research it seems to me that this is not directly possible with an entirely server-side solution?
Can someone direct me if it is possible to do so? There are many php linkedin libs, but all of them seem to direct to some sort of login from which the user is redirected back? (maybe I am mistaken here).
Any help is greatly appreciated!
Take a look if they offer public rss feeds, thats the most simple way. When they offer only protected then search for developer acces from where you can get api access.

Custom display of posts of Facebook, Twitter, Linkedi and Google+ on your website

Is it possible to shows posts, feeds etc in a customized manner on your website? For example if I don't want to use the plugins they provide to embed on your website which show posts in a rectangular box I want to show posts from these social media sites in different manner. For reference please visit this website and scroll down to section below Latest News and Testimonials you will find Facebook, Twitter, LinkedIn and Google+ with Lorem Ipsum text. It seems like this website has also not implemented this feature (don't know if its possible with all social sites) but I am asking if you need to implement something like this is this possible? I have to implement it on a PHP website, if that helps. Thanks for your help in advance.
Although you're asking for something different than embedding, I still believe what you're looking for is "Embedding posts". Most social sites do not want you to rebuild their stream experience and put it somewhere else -- additionally, most content policies on these sites prohibits you from caching or storing posts because it can easily become a privacy issue. Finally, if you're pulling a lot of posts, frequently, from these services, you will encounter API call limits.
The following resources should get you started with properly embedding posts so you don't have to worry about how you're caching:
Google+
Facebook
Twitter
If you (really, really) wanted to build out your own solution you should do it client-side in JavaScript, not in PHP. For this, you would need to use the following APIs:
Google+ uses the Activity API
Facebook has the Graph/Feed API
Twitter has the Search/Get Tweets API pass from%3A[username] to get specific user Tweets
If you were to try doing this in PHP, it would be easier using client libraries and starting from sample code.
Google+ PHP example
Facebook PHP client library
Twitter PHP client libraries
Make sure that you're following the content policies of the various sites you're aggregating. In other words, if you're doing something like caching the results in a MySQL database pulled using your PHP script, invalidate the cache every 3600 seconds and every time a post is no longer retrieved from your API calls.

how to post on google plus page stream using php/curl?

I want to post on google plus page stream using php, I checked google plus api but didn't found anything, read a post where it was saying that you can't post because google only provided read permission. When I googled I saw nextscripts SANP API to post on social networks.
If google only provided read permissions then how nextscripts is able to post?
SNAP is a paid API & I want to create my own code to do the same.
Is there anything I am missing. please guide me.
Short answer: There is no way to create a post that appears in a Google+ stream.
Medium answer: Google doesn't provide an API to post to a "normal" user's page. There are APIs that allow a website to let a user post something, and they can suggest text to post, but the user must take an explicit action. There have been attempts to use unauthorized APIs to do this, but they try to intercept the above procedure and aren't reliable. Depending on your exact needs, there are other alternatives as well.
Long answer: Depending on your exact needs, there may be some APIs which can help. But keep in mind they only apply to specific, sometimes very narrow, circumstances:
Are you trying to post to a page, not a user? There is the Google+ Page API which is available to partners only. This may be what the netxtscripts SNAP API is using - I don't know. This is what HootSuite uses, for example. You can request access at https://developers.google.com/+/api/pages-signup, but they don't approve many applicants.
Are you trying to post on behalf of a Google Apps user for other users in the same domain to see? If so, there is the Domains API at https://developers.google.com/+/domains/
Are trying to post an activity or action? Like the user listening to a song or eating at a restaurant? You may benefit from App Activities with the Moments API. These don't go directly into the stream, but are available through Search, in the user's profile in some limited ways, and they can reshare them into the stream if they wish. https://developers.google.com/+/features/app-activities
Let a user post to their stream from a web page? This still requires specific action by the user, so they have to approve what you're saying, but you can use something like normal share, +1, or interactive post buttons. https://developers.google.com/+/features/interactive-posts
You just want your server to post a plain old normal message to a normal user's stream without a person having to do anything? You can't do that.
There is still no way to post on a Google+ stream using an API. For details on what you can currently do with the limited API you can look at Google+ api
There is an issue request for this from as far back as 2011: Write access to the streams

share custom text and image on user's google plus stream using php or jQuery

I'm trying to share text and image on user's google plus stream. This text and image would be set by me. What I'm trying to achieve is, User will login to his google plus account(if not login) and then this text and image will be automatically post to his stream.
I've tried this method for sharing
https://plus.google.com/share?url=https://encrypted-tbn0.gstatic.com/images?q%3Dtbn:ANd9GcRt6YQ8bwQdOVZqTG7wls93F-bwbENvH292Lfx_TBOY9lLYL5X5RhXVRvk&hl=en
It is working fine but I want to execute this using curl or jQuery so that I can set the text and image to the respected fields and submit this at my end.But in this I'm not getting that how is it working because it is not a form.
Please help me how to do this.Please let me know if I can do this with other way.
I've go through these links also but didn't find anything useful.
https://developers.google.com/+/api/
http://www.nextscripts.com/google-plus-automated-posting/
https://developers.google.com/+/web/embedded-post/
http://www.sanwebe.com/2012/11/login-with-google-api-php
https://github.com/google/google-api-php-client
set text to google+ share button
There are two ways to automate posting to Google+. One is app activities which do not show up on Google+ streams and Google Apps users can create posts that are limited to their domain.
Outside of those two options posting to Google+ has to be done with an explicit click by the user on Google owned UI. Interactive posts and the share button are the best options.
As you can see in Official Documentation
Share Endpoint
The share link invokes the Google+ share endpoint, which you can also link to directly:
https://plus.google.com/share
The Google+ share endpoint accepts the following only query parameters:
url The URL of the page to share. This value should be url encoded.
hl The language code for the locale to use on the Google+ sharing page.
So only this is available
https://plus.google.com/share?url=http://www.Google.com
or
https://plus.google.com/share?url=http://www.Google.com&hl=ar
or
https://plus.google.com/share?url=http://www.Google.com&hl=en
The only way to prefill the text of a share is to use Interactive Posts as
You can do that by set of steps as Full Example here

Facebook api - PHP / Javascript and OpenGraph

I'm very confused so I hope that my question will make sense.
I'm working with the facebook API, and so far I've implemented login and a post to the users wall via php. I know read a bit more about the OpenGraph system, and the meta tags that you're supposed to put in your site, but I'm not quite grasping the concept og how to get my site fully PHP integrated with Facebook.
I have another login system which I've hooked facebook up to, so switching to javascript only will not be an option. Do the meta tags even matter if I use PHP only. I mean, I can't really get my head around how the token and all of that would be interpreted alongside the og: metatags if there is no javascript on the site.
Can I have BOTH php and javascript authentication? What's all that fuzz about opengraph anyway?
These are my thoughts about working with facebook, and if you'd like me to summarize this up in one question I guess it'd be:
How do I benefit from the opengraph meta tag features (tracking the users, in their timeline) when I'm only connected via PHP?
I'm confused about how the tags for specific open graph actions get interpreted like
<meta property="fb:app_id" content="xxxxxxxxxx" />
<meta property="og:type" content="myapp:read" />
and then it's supposed to post "MyName is reading lalala" or "MyName read lalala". How's the post to the server going on (if people have already authenticated via php):) ?
Unless I am misunderstanding your question, I think you are confusing how the Open Graph meta tags work. The meta tags provide external websites with exactly what they say: meta information, to be read by Facebook's "crawler". Facebook has their own web crawler that will grab certain relevant information about a webpage (for example, page title, page description, an image to associate with a webpage) so that Facebook can use that info when people "Like" or "Share" a webpage.
For example, going to https://www.facebook.com/sharer/sharer.php?u=http://example.com should illustrate how the crawler works: when someone tries to share the URL example.com on Facebook, Facebook's crawler goes to the example.com webpage and grabs relevant info, then displays it on their own page to allow you to share it with others.
The open graph tags have little or nothing to do with authenticating a user or application on Facebook's servers. They can be used totally independently of any login system that you have in place, as far as I know. All they do is provide meta information about a web page to Facebook's web crawler.
I understand your frustration with Facebook's API though - they are notoriously bad about keeping detailed, accurate information, and they change the API so frequently it's nearly impossible to keep up.
I can confirm that you're not the only one to be frustrated with the Facebook Documentation.
With that being said, i'll try to help you. As Sean said, the og graph tags have little or nothing to do with your authentication flow.
These are featured as information of what the user is doing at a certain time, like listening to a song, playing to one particular game, etc...
The Facebook's PHP SDK provides you functions to create your own objects and actions. Then you can call a $facebook->api(/...) function to indication to Facebook : My user is ACTIONS an OBJECT. Doing this, you must provide a parameter, which is the URL of the OBJECT on your Website/Application. In fact, Facebook wants you to tell him where he can finds what's this object. On a page where there's the correct meta-tags corresponding to this object ! Here are your og tags.
As you said, this will provide stories found in the timeline, or the ticker. It's those kind of things that Facebook Games use, "X is playing to Y", "Z earned the Grand Master title by playing on A", etc...
You must define those objects on your Facebook Applications Panel, and have the corresponding meta-tags on your website.
Then you just have to make the $facebook->api(/...) (or equivalent) request when this action happens on your website/application !
Everything is almost entirely explained in this tutorial : http://developers.facebook.com/docs/beta/opengraph/
Hope this will help you to find an answer.

Categories