TwitVid PHP Class

TwitVid PHP API Class

Twitvid PHP Class: Created by Marty G...
Download the Twitvid Iphone App TwitVid Iphone App


Documentation / Overview

TwitVid PHP Twitvid requires PHP5 and the lib_curl module to be compiled into your PHP build.
It also performs best when safe_mode is turned off.

All the Functions included in this class will return information from twitvid using either XML or JSON format.

Some functions will require a username and password for Twitter in order to return User specific info,
other functions can be used just to embed a particular video or user widget...

Have a look through the Example page for ideas and implementation strategies...

Function List

PHP embed_video():
Embed a Video widget on a webpage.
embed_widget():
Embed a Users Widget on a webpage.
authenticate_it():
Authenticate with Tiwtter, generate Auth Token.
list_videos():
List a users video based on username/password.
create_playlist():
Create a container for video uploads.
upload_video():
upload a single video with no tweet.
upload_video_post():
upload a single video and tweet to twitter.
get_categories():
List the Current video categories for twitvid.
delete_video():
Delete a specific video.

Status Codes

The TwitVid API attempts to return appropriate status codes for every request.

  • * 1111 OK: Success!
  • * 1001 Not Authorized: Twitter authentication credentials were missing or incorrect.
  • * 1002 Bad File: File data is missing or corrupt.
  • * 1003 Wrong File Type: File extension is not allowed.
  • * 1004 File Is Too Large: File is longer than 2Gb.
  • * 1005 1008-1012, 1014: Internal Errors.
  • * 1006 Wrong ID: Specified dedia ID is invalid.
  • * 1007 Wrong Method: Requested API method does not exist.
  • * 1013 Parameter Error: At least one of the parameters sent is invalid.

Error Messages

When the TwitVid API returns error messages, it does so in your requested format.
For example, an error from an XML method might look like this:

<?xml version='1.0' encoding='UTF-8'?>
        <rsp status='fail'>         <err code='1001' msg='Invalid twitter username or password'/> </rsp>

Class Examples

All Return calls are XML based

Embed a Single Video

embed_video()

The embed_video function
Embed a particular video using the twitVid ID
(dimmensions, height and width, are optional)

embed_video('64TUZ','600','500');

Using this function would produce an embeded video player,
ID=B1B3C,
Width=600,
Height=500

Requires Auth: NO

Example

Click to select all...

Output Response

Based on current function...



Embed a Web Widget

embed_widget()

The embed_widget function can be called to
Embed a particular widget using the username
(dimmensions, height and width, are optional)

embed_widget('mrthrust','465','350');

Using this function would produce an embeded Widget on the page, ID=mrthrust,
Width=465,
Height=350
,

Requires Auth: NO

Example

Click to select all...

Output Response

Click to select all...



authenticate_it()

The authenticate_it function can be called to
authorise your Twitter Login Details, nothing is kept on the server..

authenticate_it()

Using this function would try and login to twitvid using your twitter login details, If it fails it will tell you its failed, if it passes the login, you will have your return token, which can be used in place of the twitter login details being used all the time...

Requires Auth: YES

Example

Click to select all...

Output Response

Based on the current function



List User Videos

mrthrust

  • 1985 Suzuki LT250r QuadRacer

    Added:
    Url: 5D12C
    Views: 38


  • Me on the blaster #yamaha #blaster #quad

    Added:
    Url: AAEG5
    Views: 341


  • more blaster fun

    Added:
    Url: DJUKV
    Views: 280

    This Video has Geo-Location added ( iPhone Upload )
    GoogleMap added and Marked.


  • Up the school with a few Pit bikes

    Added:
    Url: N0SK7
    Views: 18

    This Video has Geo-Location added ( iPhone Upload )
    GoogleMap added and Marked.


  • Yamaha Blaster fun - yesterday Greenock Strone pitches

    Added:
    Url: 64TUZ
    Views: 418


  • Paddy klf 300 big jump #pladafield #portglasgow

    Added:
    Url: X1OBM
    Views: 26

    This Video has Geo-Location added ( iPhone Upload )
    GoogleMap added and Marked.


  • @shugtech #pladafields #portglasgow on the klf300 quads

    Added:
    Url: 6JJUL
    Views: 17

    This Video has Geo-Location added ( iPhone Upload )
    GoogleMap added and Marked.


  • More fun on the klf300. 4x4

    Added:
    Url: RBENH
    Views: 21

    This Video has Geo-Location added ( iPhone Upload )
    GoogleMap added and Marked.


  • @shugtech big klf300 quad jump... Ohh yea

    Added:
    Url: X8R9S
    Views: 15

    This Video has Geo-Location added ( iPhone Upload )
    GoogleMap added and Marked.


  • Paddy.

    Added:
    Url: QCATY
    Views: 7

    This Video has Geo-Location added ( iPhone Upload )
    GoogleMap added and Marked.


  • Paddy again.. This time just lands his ass...

    Added:
    Url: H2P18
    Views: 11

    This Video has Geo-Location added ( iPhone Upload )
    GoogleMap added and Marked.


  • @shugtech leg split quad jump on the klf300

    Added:
    Url: IUUOW
    Views: 10

    This Video has Geo-Location added ( iPhone Upload )
    GoogleMap added and Marked.


  • Dougal klf jump and paddy given it some wheelies up the hill...

    Added:
    Url: OP843
    Views: 16

    This Video has Geo-Location added ( iPhone Upload )
    GoogleMap added and Marked.


  • More uphill wheelies from paddy

    Added:
    Url: RZ1Q1
    Views: 11

    This Video has Geo-Location added ( iPhone Upload )
    GoogleMap added and Marked.


  • Just plain stuck... In a whole heap of shite

    Added:
    Url: CZVTO
    Views: 25

    This Video has Geo-Location added ( iPhone Upload )
    GoogleMap added and Marked.


  • Marty on the 200 yamaha blaster

    Added:
    Url: H1WQQ
    Views: 74


  • My longest wheelie session yet on #trialshd can go to bed now :) Bring on #trialsevolution

    Added:
    Url: DHSDK
    Views: 19


List_videos()

The list_videos will return a 'Users' list of videos.
If the videos have been tagged with there lat & long google maps can be used to mark them,

username: Required
source: Optional, Select which videos to list (Web, API, Mobile)
page: page number starting at 1
page_size: Optional Number of videos to be returned
order_by: Optional, Date or view count (date,views)
format: XML by default

list_videos();

Using this function would produce a list of all the users videos,
username=twitter_username,

Requires Auth: NO

Example

Click to select all...

Output Response

Based on the current function



Create Playlist

Twitter Username:
Twitter Password:
Playlist Name:

create_playlist()

The create_playlist function can be called to
Create a container in which to upload videos into!
Once you create your playlist you can pass this playlist value along with your video upload
create_playlist()

Using this function would create a playlist container, with its returned value being used to pass into the upload paramaters along with your video media. If it fails it will tell you its failed, if it passes the login, you will have your return ID, which can be used alongside the upload function...

Requires Auth: YES

Example

Click to select all...

Output Response

Click to select all...



Basic Video Upload

Twitter Username:
Twitter Password:
Message
File:

.3gp .3g2 .asf .asx .avi .flv .m4v.mkv
.mov .mp2 .mp4 .mpg .mpeg .ogv .qt .wmv

upload_video()

The upload_video will take advantage of the Twitter username & password of the user and let them upload a video direct to twitvid...without tweeting a message to twitter.. (see upload_video_post() for information on how to post the message to twitter)...

The order of the passed in parameters is important. Always pass in the media data as the last parameter. Otherwise an error will be returned.

upload_video($message, $media)

$message : The message to be tweeted.
$media : Required. Binary video data must be posted as multipart/form-data

Requires Auth: YES

Example

Click to select all...

Output Response

Click to select all...



Video Upload & Post

Twitter Username:
Twitter Password:
Your Message 140 !
File:

.3gp .3g2 .asf .asx .avi .flv .m4v.mkv
.mov .mp2 .mp4 .mpg .mpeg .ogv .qt .wmv

upload_video_post()

The upload_video_post will also take advantage of the Twitter username & password Use this method to upload a video and send out a tweet to Twitter...

The order of the passed in parameters is important. Always pass in the media data as the last parameter. Otherwise an error will be returned.

upload_video_post($message, $filename)

$message : Optional. The message to be tweeted.
$filename: Required. Binary video data must be posted as multipart/form-data

Requires Auth: YES

Example

Click to select all...

Output Response

Click to select all...



Get Categories

get_categories()

The get_categories take advantage of the Twitter username & password Use this method to output a list of twitvid categories

get_categories()

Requires Auth: YES

Example

Click to select all...

Output Response

Click to select all...


Download

TwitVid PHP API Class

A comprehensive PHP implementation of the most important Twitvid API functionalities that enables programmers to interact with Twitvid in their own web applications easily.

Post new videos to Twitvid by adding a few lines of code to your app!

Current Version: 1.2

** Changelog **
1.2: Updated Twitvid URL's
1.1: Added the Ability to retreive the Categories
1.0: User Authentication fixed

Download Class

If you really like the work, then feel free to Donate and buy me a coffee.. :)