forked from stevencorona/php-twitpic
/
EXAMPLE.php
54 lines (43 loc) · 1.58 KB
/
EXAMPLE.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?
include('TwitPic.php');
/*
* All of this info is needed only for API calls that
* require authentication. However, if the API call doesn't
* require authentication and you provide the information anyways,
* it won't make a difference.
*/
$api_key = ""; // your TwitPic API key (http://dev.twitpic.com/apps)
$consumer_key = ""; // your Twitter application consumer key
$consumer_secret = ""; // your Twitter application consumer secret
$oauth_token = ""; // the user's OAuth token (retrieved after they log into Twitter and auth there)
$oauth_secret = ""; // the user's OAuth secret (also from Twitter login)
/*
* The TwitPic() constructor can be left blank if only
* doing non-auth'd API calls
*/
$twitpic = new TwitPic($api_key, $consumer_key, $consumer_secret, $oauth_token, $oauth_secret);
try {
/*
* Retrieves all images where the user is facetagged
*/
$user = $twitpic->faces->show(array('user'=>'meltingice'));
print_r($user->images);
$media = $twitpic->media->show(array('id'=>1234));
echo $media->message;
$user = $twitpic->users->show(array('username'=>'meltingice'), array('process'=>false, 'format'=>'xml'));
echo $user; // raw XML response data
/*
* Uploads an image to TwitPic
*/
$resp = $twitpic->upload(array('media'=>'path/to/file.jpg', 'message'=>'This is an example'));
print_r($resp);
/*
* Uploads an image to TwitPic AND posts a tweet
* to Twitter
*/
$resp = $twitpic->uploadAndPost(array('media'=>'path/to/file.jpg', 'message'=>'Another example'));
print_r($resp);
} catch (TwitPicAPIException $e) {
echo $e->getMessage();
}
?>