Is there any way to share link of specific website through my twitter account with PHP? Instead of going to that website and clicking share and authenticating and posting, can i do all this with PHP? If yes, how? Meanwhile, I've managed to get the desired format for posting:
$tweeter_link = "https://twitter.com/share?original_referer=" . $link . "&related=&source=tweetbutton&text=" . $title . "&url=" . $link . "&via=SomeThing";
But I can't process it properly with curl.
Related
I'm using the Facebook Comments plugin (from FB, not a WP Plugin) on my WP site.
I want to get the number of comments for a specific URL, so I can set it up to say "start the conversation" or "join the conversation"
I've done my research and found several variations on the code below posted as recently as April of this year:
$rest_url = "http://api.facebook.com/restserver.php?format=json&method=links.getStats&urls=https://my.com/".$my_slug;
$json = json_decode(file_get_contents($rest_url), true);
// echo "Facebook Shares = " . #$json[0]['share_count'];
// echo "Facebook Likes = " . #$json[0]['like_count'];
echo "Facebook Comments = " . #$json[0]['comment_count'];
However, after some frustration, I realized I needed to dump $json and see what's in there:
var_dump($json);
and to just parse out the important part, there was a message inside:
"REST API is deprecated for versions v2.1 and higher (12)"
There's a lot I don't understand about APIs and Facebook's system.
But... can you tell me what the current way of getting the comment count is now? I just need it in a variable and I can go from there.
Thanks for any help!
Chris
I am trying to use a twitter API to display the latest tweets in an area. the code sort of works and shows the message, timestamp when the tweet was posted and what was used to make it. however, I want to show the profile images and usernames of the people that posted them. but I keep getting the following error for both name and profile image:
Notice: Undefined index: get_tweets.php on line 40
here is the link for the web page that requests the tweets:
https://dl.dropboxusercontent.com/u/22591742/get_tweets.php
and the link to the API that I'm using:
https://dl.dropboxusercontent.com/u/22591742/TwitterAPIExchange.php
thanks in advance!
-Filip
Some of the properties you're trying to access are nested within the user array.
So profile_image_url and name are both within the user array.
You should reference them like so:
$status["user"]["profile_image_url"]
So for the line of your code where you're outputting the details from $status
echo("<p>". $status["user"]["profile_image_url"] . $status["user"]["name"] . "<b>Created at: </b>". $status["created_at"] . "<br/>". $status["source"] . "<br/>" . $status["text"] . "</p>");
I'm trying to connect an app to a facebook page ... up till that it's fine as it displays in the tabs. Also a simple echo works fine.
I'm using this guide to get it working: https://www.webniraj.com/2014/06/11/facebook-api-creating-page-apps-using-facebook-php-sdk-4-0-x/
I have tried to set some echos so I'd know where it's getting stuck and from what I have it seems it's getting stuck in the
$pageHelper = new FacebookPageTabHelper();
The code works fine on the server where it is uploaded
Any help would be appreciated,
Thanks :)
That tutorial is aweful. All those require calls when you could just use the existing autoloader.php instead. FacebookPageTabHelper extends FacebookCanvasLoginHelper, so you don´t have to add it separately.
Try this one instead: http://www.devils-heaven.com/facebook-php-sdk-4-0-tutorial/
See "Using the Page Tab Helper" in the article:
require 'phpsdk4/autoload.php';
use Facebook\Helpers\FacebookPageTabHelper;
FacebookSession::setDefaultApplication('APP-ID', 'APP-SECRET');
$helper = new FacebookPageTabHelper();
echo '<p>page id: ' . $helper->getPageId() . '</p>';
echo '<p>liked: ' . $helper->isLiked() . '</p>';
echo '<p>admin: ' . $helper->isAdmin() . '</p>';
Important: You need PHP 5.4+ to use the new PHP SDK. - If the code does not work, it´s most likely a problem with the server.
google login
I am working on php . I have made app on Google . If u can see my link , I am using state parameter , in which state=reg . In my callback page , I am trying to get this value ie $_get['state'] but its not showing me anything . Am i doing the right way ?
I've never seen a Client ID that begins "**", but in your link I see client_id=%2a%2a43760%2a%2a%2a%2a%2a-cp7 which really looks wonky. Are you sure that’s right?
I was wondering if it was possible to use PHP / AJAX to have a string of text sharable to Facebook? For example, I use PHP to return an SQL query, then use that same string of text in correspondence with a button, to share to my Facebook wall. So, it might look something like this in the PHP:
while($note_row = mysql_fetch_row($result)) {
echo '<p> "' . $note_row['my_note_text'] . ' "</p>';
echo '<input type="button" id="' . $note_row['my_note_id'] . '" class="share-to-facebook" value="share" />';
}
If anyone has some advice whether this is possible I'd be super happy. I also apologise if my PHP is wrong, I haven't checked it.
You have some options:
sharer.php
https://www.facebook.com/note.php?note_id=407822831963
Create a share link. You can set title and url.
Feed Dialog
https://developers.facebook.com/docs/reference/dialogs/feed/
Creates a share dialog. More options for description and image etc. Might be a replacement for sharer.php.
If you need to post to the wall from your app, you need the get permissions by having the user accept your app to Facebook. Read more about authentication at https://developers.facebook.com/docs/authentication/