Wordpress share twitter via twitpic - php

my question a little complicated.
I want to share a featured image which is in a post on my wordpress site to twitter.
But there a important point. i want to share a picture with twitpic because of people can see this image in twitter without open my web site.
i get api from twitpic, and i use this code (link)
but twitpic or this code cannot accept a url to upload twitpic and get a link.
$resp = $twitpic->upload(array('media'=>'$a2', 'message'=>'get_the_title()'));
if i wrote $a2 = "ex.jpg" its working,
if i wrote $a2 = "http://www.ex.com/ex.jpg" not working
then i try that;
<?php
$a1 = $_SERVER['DOCUMENT_ROOT'];
// ex image remove 18 chr from begining http://*******.com/wp-content/uploads/2013/04/2012-10-17-23.48.34.jpg
$kisalt1 = $imageshare[0]; // wordpress featured image fxn ex: http://*******.com/wp-content/uploads/2013/04/2012-10-17-23.48.34.jpg
$kisalmis = substr($kisalt1,18,9999);
$a2 = $a1.$kisalmis;
// echo $a2; => /home/*******/public_html/wp-content/uploads/2013/04/bu-terste-bir-islik-var-panpa.jpg
?>
but it stil give same error.
Unable to find or read file
how can i get ride of this?
summary => i want to this => wordpres featured image to twitpic for share twitter like image which can open without click a link.

Edit: I just tried deleting this because I saw that you said that http://www.ex.com/ex.jpg doesn't work for you. But then I thought this might still be helpful (to someone), and for some reason the comments option didn't show up for me, so here it is again. Sorry if it doesn't help though.
What you need is just the post_thumbnail url, not the full image tag.
http://wordpress.org/support/topic/getting-post-thumbnail-url
The relevant post is the one with this code block:
$a2 = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
Does it work if you add that?
-Andrew
Another edit...I just came across this post on the Wordpress StackExchange site: https://wordpress.stackexchange.com/questions/83137/post-thumbnail-relative-link-and-html-modify
Does it work if you provide TwitPic with a relative link location?

Related

Set Description, Draft and Permalink using Blogger API with PHP

I really need your help with this matter. I'm looking for a solution for about 3 months now, but really the Blogger API is not easy to deal with because Blogger don't even provide examples.
I can create and publish new posts with PHP script and I have done all things, but I can't set the Post's description, permalink, or even making the new post as draft.
The following is a piece of my code that creating the post.
<?php
$mypost = new Google_Post();
$mypost->setTitle('My Post Title');
$mypost->setContent('This is My Content');
$mypost->setLabels( array( 'News','Weather', 'Media' ) );
$mypost->setCustomMetaData('My_CUSTOM_META_DATA' . time()); // Nothing changed
$mypost->setcustomMetaData('This is the description for you'); //Nothing Changed
$mypost->setDescription('New Description'); // Nothing Changed
$mypost->setUrl('testseturl'); // Nothing Changed
$mypost->setPublished('2021-08-27T23:07:00-07:00'); // Worked as Schedule post
$data = $blogger->posts->insert('My BlogID', $mypost);
echo "<pre>";
var_dump($data);
echo "</pre>";
?>
As you can see I can't set the permalink and I tried several thing such as adding the full URL, and also adding only the custom permalink text + html, but I failed.
I tried also the description several times, but every time I found the description's post empty.
Also I can' set the post as Draft and I have to do this manually from the blog itself.
Blogger doesn't provide any help docs for PHP, and the new Beta client library on github is for all Google products and I wasn't able to use it. I use the library Google API PHP Client 0.6.7 found here although it's deprecated.
The only topic I found in this blog, and it's the same code that I use, but he didn't mentioned anything about permalink, draft, or description.
Please help me as you can.
Thanks.
permalink
Unfortunately there is no way to set custom permalink to the posts using Blogger api, even the official "Try this API" tool don't have this feature, your code is fine it's just Blogger don't support it.
custom description
I don't think there is a way to add custom description as well, setDescription is not a valid method, you can check all the supported methods here
draft post
to create a post draft you can do it like this
$optParams = array('isDraft' => true);
$data = $blogger->posts->insert('My BlogID', $mypost, $optParams);

PHP - WordPress Script To Get Random Line From Text File

Good day. I have a WordPress plugin script here that as below works fine in doing what it should. What I am having trouble with is editing/appending the script to do one additional task that I need. What the plugin does is setup a category in WordPress and then every hour go get a video from Youtube and create a post on the blog.
So for example, if I typed in create category: Siberian Husky's then that category would be created and every hour the script will go get a new video title, video embed and description related to Siberian Husky's.
(How the title is created now with the script ->) Let's say the first video it get's the title on Youtube is this: White Siberian Husky's Are Loveable
That would be the title to the WordPress post. What I want to do is place a text file on in my sites root directory called /phrases.txt and on each line would be a new phrase. I want this script to go get randomly a new phrase from that text file and put it "in front" of the Youtube title.
(How I want the output to be after getting a random line from my text file ->) So when the post is made on the blog the title would be: Here Is My Phrase From Text File : White Sibeian Husky's Are Loveable
I hope I made that clear enough. Below is the entire script that get's the data for the video post on the blog.
I believe around line 1861 is where the script writes the title, don't quote me, I am not positive. That part of the code looks like:
// and create a post
$wpvt_post = array(
'post_title' => $content->items[0]->snippet->title,
'post_content' => $post_content,
'post_author' => $item['item']['post_author'],
'post_status' => $item['item']['post_status'],
);
Where the ->title, is creates the title for the post. I am not sure what to change or add to have the script go to my text file and get my phrase I want to add to the title.
Here is a link to the entire script --> http://textuploader.com/kg8m
It was to large to paste into this post, sorry.
Thank you for your help.
i had not added in wordpress code here but still in PHP code it's working fine for me you had just add to this code in wordpress format. As per wordpress query and all those things.
code is here.
<?php
$f_contents = file("random.txt");
$line = $f_contents[rand(0, count($f_contents) - 1)];
?>
<?php
/*-----------------------------------------------------------------------------
Pull out a random quote from the quote file and display it.
-----------------------------------------------------------------------------*/
function random_phrase ()
{
$quotes = file ("wp-content/quotes.txt");
$num = rand (0, intval (count ($quotes) / 3)) * 3;
echo $quotes[$num] . "<br>" . $quotes[$num + 1];
}
?>
Now just put this little bit of code where you want the quote to appear:
<?php random_phrase (); ?>

Display Number of Facebook Likes as Text

I'm trying to create a widget like the Facebook widget found on this site. I'm not sure how they've done it but somehow they're pulling in the number of Facebook likes from their page via the API. I've found a few examples online but none seemed to work. Is it possible someone could point me in the direction of how I can display the number of Facebook likes (for a page) as text?
Please note that the site I need it for is Wordpress so either an existing plugin or just PHP code will work!
This is how you can do it in php:
$fb_handle = "GideonShalwickUpdates";
$graph_url = "https://graph.facebook.com/".$fb_handle."?fields=likes";
$get_data = file_get_contents($graph_url);
$get_json = json_decode($get_data);
$likes = $get_json->likes;
echo $likes;

Instagram: how to get the info of a single picture?

I have a page that shows the latest 50 pics of a certain #hashtag.
I'd like the user to click on the image and go to a page, of the same website, where I can show the full size pic, the title ....
I've searched a lot but I cannot find a way to get the info of a single picture.
Something like this: http://snapwidget.com/view/?id=273145283494542941_10884350#.UE9ukhhwPw8
Thank you!
Have you checked out the Instagram API?
You can use:
https://api.instagram.com/v1/media/MEDIA-ID?access_token=ACCESS-TOKEN
to get the info I've passed the image id in a $_GET variable... Something like this:
http://yoursite.com/image.php?id=3
<?php
//image.php
$image = $_GET['id'];
$info = 'https://api.instagram.com/v1/media/'.$image.'?access_token='.$token;
$response = json_decode($info, true);
//example for full size image
$fullsize = $response['images']['standard_resolution']['url'];
echo '<img src="'.$fullsize.'"/>';
?>
EDIT: also have a look at THIS, it's a PHP wrapper for Instagram, very useful!
I use the shortcode:
From the imgage url, I get the shortcode: eg.: https://instagram.com/p/2rqCzTTdUX/ -> 2rqCzTTdUX
Then, with the following endpoint:
https://api.instagram.com/v1/media/shortcode/{shortcode}?access_token=ACCESS_TOKEN
I get the same data as with the media/{media_id} api. Then, I look for the param 'id' at top level
of data (in the json api's response) -> '985065853803556759_429959980'
Finally, for example, I can use the api get media:
v1/media/{media_id}?access_token=ACCESS_TOKEN

Tagging photos on Facebook with Graph API / PHP SDK

The question is pretty much in the title, but to be more specific, I'm working on a facebook contest for a client in which people have to upload photos to take part in it after accepting rules and subscribing, etc.
After going down a long road full of deceptions
(here's what I tried that didn't work in the end:
uploading to the user's album then tagging the page: nope, can't tag a page
uploading to a public album in the page, like "fan photos", or wall photos? can't find anything AT ALL about a way to do this, though it would've been my preferred way.)
So, I ended up having an idea: I would do this in two steps. First, the user subsribes and uploads a photo to my PHP server. Then, another, different application with permissions on the account that has the page, would take control of it, upload all the photos at 5 minutes intervals (meaning, you subsribe, 5 minutes later, your photo's uploaded.)
So far, so good; I don't like the logic behind this, but it's the only way I found! So, I did the base, I'm able to post a photo with a caption as the page in a dedicated app album.
BUT! I can't tag anyone in those photos. Maybe you can't tag as a page, maybe you can't tag in page albums, maybe I don't have the permissions required (I have stream_publish, user_photos, friends_photos, offline_access, and I could add anything if I need to since it's a private-use app anyway). Oh and, the user I'm trying to tag is the admin for both the app and the page (and he likes the page). I don't know, but it's driving me crazy. I hate the official documentation, there's no example code, you have to figure out most of the things, go through trial and error or search on the web for people who did so and shared how to do things. Not nice when you have little time to complete a project for a client without busting the budget.
Anyway, here's my error I keep getting whenever I try to tag someone to a photo from any album:
OAuthException: (#322) Invalid photo tag subject
And here's the code I'm using to upload a photo from the server to facebook.
if ($user) {
try {
$page_info = $facebook->api("/$page_id?fields=access_token");
if( !empty($page_info['access_token']) ) {
// First method, at the same time as upload. Upload works but no tags
$args = array(
'access_token' => $page_info['access_token'],
'source' => '#' . realpath($FILE_PATH),
'message' => "test"
'tags' => array(
array(
'tag_uid'=> "MY_USER_ID",
'x' => 0,
'y' => 0
))
);
$post = $facebook->api("/$page_id/photos","post",$args);
$postID = $post['id'];
// Second method I'm trying. No tags.
$tag = $facebook->api("/$postID/tags/MY_USER_ID","post");
print_r($tag);
}
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
Any help would be appreciated. Thanks in advance!
EDIT :: Now I got it partly working using the second part in the code, but only if I remove the "access_token" parameter from the photo posting first. Basically, it only works if I upload it to a personal album. But that's as far as it gets from what I want. When I upload it to the album from the page, it says I asked for tag requests, but on my personal account which I tagged, I don't receive anything. Baaaah.
RE-EDIT :: After much tries, it seems I can't tag someone as a page or in a page album. I'll try to find an alternative, I guess.

Categories