23
Mar
2015

Tweet Images Via API Using Codebird-PHP

posted Monday, March 23rd 2015 at 8:37 AM by

Tweet Images with Codebird-PHP

I wrote up a little tutorial earlier on how to tweet automatically using PHP, but I didn't cover how to Tweet media and images using the same API. Well here it is, a couple code snippets on how to tweet images using Codebird-PHP. Enjoy!

Continue Reading...

Tags:

Comments:

View (8) Comments Post a Comment
  • Replying to Adam Konieska on Tweet Images Via API Using Codebird-PHP







  • sin
    Sin
    Sunday, August 16th 2015 at 5:10 PM

    What is $image? Is it the logical path for the image on the server? Is it the URL from the browser? Is it the absolute path?

    • Replying to Sin







    • Adam Konieska
      AK
      Sunday, August 16th 2015 at 7:11 PM

      Hey Sin, $image is the full URL of the image. Twitter grabs the image from that URL and re-hosts it on its servers.

      Check out the example call at the bottom of the code snippet.

      Hope that helps!

      • Replying to AK







  • ron nuberg
    Ron Nuberg
    Wednesday, August 24th 2016 at 5:45 AM

    Adam, did you already try adding meta data to an image, I have tried media/metadata/create calling codeBird->media-metadata-create, but the function is not found. I am trying to upload a single picture and I believe it needs to be a multiple picture setup for this to wotk? What do you think?
    Thanks
    RonN

    • Replying to Ron Nuberg







    • ron
      ROn
      Wednesday, August 24th 2016 at 6:56 AM

      I found it, added and extra item to the POST array for this method.
      Picture got posted, but I saw no tags, so hunting on ;-)

      • Replying to ROn







  • shirish
    Shirish
    Friday, January 27th 2017 at 7:54 AM

    Is it possible to tweet with only Image URL in case I have only image cdn URL

    • Replying to Shirish







    • Adam Konieska
      AK
      Friday, January 27th 2017 at 12:52 PM

      Of course! Just use the CDN url in the function call.

      • Replying to AK







  • bob
    Bob
    Saturday, March 11th 2017 at 9:11 AM

    This is a great help! Thanks so much for posting this. I was using Twitter OAuth REST API Library, then I did a google search for a simple way to post media to Twitter and found this, which is how I found out about codebird! It seems so simple and lightweight. I really like it!

    I have a question though. I am trying to post video, an MP4 to twitter. I used the basic example code for video posting included in codebird and used your idea of turning it into a function like you did here for this image upload example.

    The one thing the function is missing is some error handling so the function returns the error message that twitter replied with, or true if no errors were returned, and a tweet could be posted with the attached video. Any idea on how to best accomplish this? Do you already have a video upload codebird example post somewhere on your blog that I missed maybe? Do you have other examples using codebird in functions with error handling? Thanks a lot for the examples and all the help you are providing! AWESOME!

    • Replying to Bob







  • piotr
    Piotr
    Monday, June 12th 2017 at 8:39 AM

    Hello
    I have a problem with this message, please help, hint what I can do. Thank you.

    Notice: Undefined property: stdClass::$media_id_string
    stdClass Object ( [errors] => Array ( [0] => stdClass Object ( [code] => 89 [message] => Invalid or expired token. ) ) [httpstatus] => 401 [rate] => )

    • Replying to Piotr







20
Feb
2015

Generate bit.ly Short URLs with PHP

posted Friday, February 20th 2015 at 8:40 AM by

Generate bit.ly Short URLs with PHP

Need to shorten URLs automatically for your website (or automated Twitter feed)? No problem, bit.ly has a neat API that you can connect to via PHP!

Continue Reading...

Tags:

Comments:

View (4) Comments Post a Comment
  • Replying to Adam Konieska on Generate bit.ly Short URLs with PHP







  • kirk ward
    Kirk Ward
    Monday, May 18th 2015 at 6:47 PM

    I'm trying to use the bitly.php as described, using the function and the example URL inside a Wordpress page. All goes well until I try to echo the bit.ly shortened link. The message I get is "Array."

    You can see my result at http://practicebuilderpublishing.com/code-test

    The URL above the bitly.php output is the typical dynamic URL I want to shorten, using bit.ly and bitly.php.

    Can you advise me as to where I have an error?

    Or, has bit.ly changed their api since the post was written?

    Many thanks
    Kirk Ward

    P.S. Are you the developer? (I have a hard time figuring simple things like this out. I'm starting to use age as an excuse.)

    • Replying to Kirk Ward







    • Adam Konieska
      AK
      Wednesday, May 20th 2015 at 3:12 PM

      Hey Kirk! The first thing I'd check would be the API keys and the bit.ly account.... but it looks like you've already got it working from our email exchange. Nice job! If you need anything else, just drop me a line!

      • Replying to AK







      • huw
        Huw
        Tuesday, May 30th 2017 at 8:09 AM

        Hi Adam - it looks like the bitly.php file has changed https://github.com/Falicon/BitlyPHP can you update the tutorial on how we should edit the file to include our authentication etc

        • Replying to Huw







  • ramon michael
    Ramon Michael
    Thursday, December 17th 2015 at 11:44 AM

    Thanks for the very helpful tutorials Adam, this one as well as the auto posting to Twitter one. Both are very well explained with nice screenshots.

    • Replying to Ramon Michael







16
Feb
2015

Post to Twitter Via API Using Codebird-PHP

posted Monday, February 16th 2015 at 8:57 AM by

Auto Tweet Using PHP

Do you have a website with frequent updates? Maybe you're driving traffic to those updates via Twitter? Push those updates directly to Twitter via the API and PHP!

Continue Reading...

Tags:

Comments:

View (14) Comments Post a Comment
  • Replying to Adam Konieska on Post to Twitter Via API Using Codebird-PHP







  • rendy
    Rendy
    Monday, June 29th 2015 at 1:41 AM

    It's working with my localhost, but when i upload to my website, why it doesn't working. Thanks, please reply to my email.

    • Replying to Rendy







    • Adam Konieska
      AK
      Monday, June 29th 2015 at 10:13 AM

      Aww shoot. I'll send you an email and hopefully we can troubleshoot it!

      • Replying to AK







      • test
        Test
        Wednesday, November 4th 2015 at 6:56 AM

        Nice Post

        • Replying to Test







  • james
    James
    Sunday, July 12th 2015 at 9:29 AM

    "You'll need these for the next step in configuring Codebird." - What next step? I seem to be missing something, which may be causing the following problem:

    When I run the tweet() function above it displays codebird.php as a webpage.

    • Replying to James







    • james
      James
      Sunday, July 12th 2015 at 10:21 AM

      Never mind! :)

      • Replying to James







  • anders
    Anders
    Saturday, September 12th 2015 at 10:05 AM

    Cool! Works perfectly. How do you tweet like this with a image? :-) Thanks!

    • Replying to Anders







    • anders
      Anders
      Saturday, September 12th 2015 at 2:28 PM

      Nevermind, found your other post that describes tweeting with image :)

      • Replying to Anders







      • Adam Konieska
        AK
        Saturday, September 12th 2015 at 2:55 PM

        Awesome Anders, glad you found it. Here's the link if anyone else is also looking: http://www.adamkonieska.com/archives/tweet-images-via-api-using-codebird-php/

        • Replying to AK







  • gary
    Gary
    Wednesday, November 11th 2015 at 9:25 PM

    THANK YOU! I've been trying for a while to find a script that does this easily. Yours works like a charm!!

    • Replying to Gary







    • Adam Konieska
      AK
      Thursday, November 12th 2015 at 8:24 AM

      Thanks Gary! That's awesome to hear.

      • Replying to AK







  • david
    David
    Thursday, March 3rd 2016 at 1:02 PM

    I got codebird.php to work but it's sending posts automatically without me having to create a cron job. Where in the code can I change the time of the auto posting?

    Thanks.

    • Replying to David







    • Adam Konieska
      AK
      Thursday, March 3rd 2016 at 5:40 PM

      Hey David. The code (as shown here) wouldn't run on its own. The code would do a tweet every time the tweet() function is executed - so if someone is accessing a URL that causes the script to run, it would post. If you wanted to set something to post at a specific time you could do it using a cron job.

      Hope that helps!

      • Replying to AK







  • malik
    Malik
    Friday, August 5th 2016 at 7:37 AM

    I want to post a tweet on behalf of my website users. They have already give me auth_token and auth_token_secret but the obove code is not working for it. and the Error is HTTP_CODE is 401.

    • Replying to Malik







    • Adam Konieska
      AK
      Friday, August 5th 2016 at 1:58 PM

      Hey Malik, the 401 status code is a pretty good indicator that there is a problem with your auth credentials. More details on the 401 status code.

      • Replying to AK







20
Jan
2015

Adding an Image Watermark with PHP

posted Tuesday, January 20th 2015 at 8:51 AM by

Create an Image Watermark with PHP

PHP has some pretty neat tools for manipulating images. Using some of those tools, we can add watermarks to images automatically. Lets take a look at the example code.

Continue Reading...

Tags:

Comments:

View (0) Comments Post a Comment
  • Replying to Adam Konieska on Adding an Image Watermark with PHP







17
Dec
2014

Scraping Images from a Website in PHP

While working through some SEO enhancements for Homebräu, like building Sitemap with images, I needed to find a way to gather all the images on a page and return them nicely. I also needed to use this logic in a couple places, so it needed to be flexible.

Here is tutorial for creating a script that will scrape a page or HTML string for images, and return all of their src attributes. Let's look at the PHP first...

Continue Reading...

Tags:

Comments:

View (1) Comments Post a Comment
  • Replying to Adam Konieska on Scraping a Website for Images with PHP to build an Images sitemap.xml







  • sunny techo
    Sunny Techo
    Saturday, July 9th 2016 at 1:51 AM

    There is correction in function "scrapeImages"
    because its always return empty array.
    In this line,
    array_push($img,$image->getAttribute('src'));
    Improve
    array_push($imgArray,$image->getAttribute('src'));

    • Replying to Sunny Techo







8
Dec
2014

How to Fetch a Gravitar Image With PHP

posted Monday, December 8th 2014 at 8:45 AM by

Gravitar Icon

When I added Gravitar support for Homebräu I ran into a little hiccup for users that didn't have a Gravitar image. I needed to find a way to check to see if a Gravitar image exists in PHP, then stop Gravitar from returning the default image, which is just the boring Gravitar icon.

I managed to work it out by...

Continue Reading...

Tags:

Comments:

View (0) Comments Post a Comment
  • Replying to Adam Konieska on How to Fetch a Gravitar Image With PHP







25
Nov
2014

Improved Image Sitemap Support for Homebräu CMS

posted Tuesday, November 25th 2014 at 8:09 AM by

Hessen Haus, Des Moines, IA

As Homebräu continues to evolve it continues to add SEO features. I covered how to use a Sitemap to improve your SEO, and how I automated Sitemaps in Homebräu. Well, if an image is worth a thousand words, the next step is to include fully automated image Sitemaps in Homeäu.

The process is simple, and doesn't require any action from the user. Homebräu does it all behind the scenes by...

Continue Reading...

Tags:

Comments:

View (0) Comments Post a Comment
  • Replying to Adam Konieska on Improved Image Sitemap Support for Homebräu CMS







6
Oct
2014

Rise of the Machines! A Spam Story

posted Monday, October 6th 2014 at 8:14 AM by

Terminator 2: Spam Day
The Skynet Funding Bill is passed. The system goes on-line August 4th, 1997. Human decisions are removed from strategic defense. Skynet begins to learn at a geometric rate. It becomes self-aware at 2:14 a.m. Eastern time, August 29th. In a panic, they try to pull the plug.

It was bound to happen sooner or later, spam bots hitting the comment forms over and over! I was getting around 2,000 comment submissions per day from these friendly robots bent on world domination.

I could reduce it with one of those clunky off the shelf captchas, but lets face it, they aren't without their problems either, especially...

Continue Reading...

Tags:

Comments:

View (0) Comments Post a Comment
  • Replying to Adam Konieska on Rise of the Machines! A Spam Story







8
Sep
2014

Homebräu - Announcing Improved Caching

posted Monday, September 8th 2014 at 11:21 PM by

Cache Diagram

I'm very excited to announce improvements to caching in Homebräu CMS. After combing through pages and the core CMS design, I identified areas that frequently performed calculations and/or database queries. Pages like that used to be generated upon request.

Not anymore....

Continue Reading...

Tags:

Comments:

View (0) Comments Post a Comment
  • Replying to Adam Konieska on Homebräu - Announcing Improved Caching







11
Aug
2014

Introducing Homebräu - The CMS with the German Sounding Name

posted Monday, August 11th 2014 at 10:48 PM by

World, meet Homebräu. Homebräu, meet the world.

echo('Hello world!');

Heh, I'm sure you two are going to get along great.

Homebräu CMS

My website is powered entirely by Homebräu. It allows me to create and manage entries, pages, and files in a simple way.

Which is pretty awesome.

Continue Reading...

Tags:

Comments:

View (5) Comments Post a Comment
  • Replying to Adam Konieska on Introducing Homebräu - The CMS with the German Sounding Name







  • ben myhre
    Ben Myhre
    Tuesday, August 12th 2014 at 6:31 AM

    Very cool, Adam!

    • Replying to Ben Myhre







  • tim mcmichael
    Tim McMichael
    Tuesday, August 12th 2014 at 10:14 AM

    Very sweet Adam!

    • Replying to Tim McMichael







  • Adam Konieska
    AK
    Tuesday, August 12th 2014 at 2:25 PM

    Thanks guys!

    • Replying to AK







  • toops
    Toops
    Wednesday, August 13th 2014 at 5:54 PM

    Good for you for taking on the challenge and fun in doing it yourself! You showed the first few lines of code above in what looks like vim. Did you code the whole thing in a command line editor or a Win-based editor? I'm impressed regardless, but If the former, that'd be even more epic... and also explain why it took so long, lol.

    • Replying to Toops







    • Adam Konieska
      AK
      Wednesday, August 13th 2014 at 8:39 PM

      Nah, I mostly used Sublime Text, which is an awesome editor.

      • Replying to AK