Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

Commit a29fbf9

Browse files
author
JamesMallison
committed
Merge branch 'master' of https://github.com/J7mbo/twitter-api-php into develop
2 parents 208823f + 4f3e89f commit a29fbf9

File tree

2 files changed

+47
-29
lines changed

2 files changed

+47
-29
lines changed

README.md

Lines changed: 41 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
twitter-api-php
2-
======================
2+
===============
3+
34
Simple PHP Wrapper for Twitter API v1.1 calls
45

56
[![Total Downloads](https://poser.pugx.org/j7mbo/twitter-api-php/downloads.png)](https://packagist.org/packages/j7mbo/twitter-api-php)
@@ -40,51 +41,64 @@ Installation
4041
Of course, you'll then need to run `php composer.phar update`.
4142

4243
How To Use
43-
------
44+
----------
45+
4446
#### Include the class file ####
4547

46-
require_once('TwitterAPIExchange.php');
48+
```php
49+
require_once('TwitterAPIExchange.php');
50+
```
4751

4852
#### Set access tokens ####
4953

50-
$settings = array(
51-
'oauth_access_token' => "YOUR_OAUTH_ACCESS_TOKEN",
52-
'oauth_access_token_secret' => "YOUR_OAUTH_ACCESS_TOKEN_SECRET",
53-
'consumer_key' => "YOUR_CONSUMER_KEY",
54-
'consumer_secret' => "YOUR_CONSUMER_SECRET"
55-
);
54+
```php
55+
$settings = array(
56+
'oauth_access_token' => "YOUR_OAUTH_ACCESS_TOKEN",
57+
'oauth_access_token_secret' => "YOUR_OAUTH_ACCESS_TOKEN_SECRET",
58+
'consumer_key' => "YOUR_CONSUMER_KEY",
59+
'consumer_secret' => "YOUR_CONSUMER_SECRET"
60+
);
61+
```
5662

5763
#### Choose URL and Request Method ####
5864

59-
$url = 'https://api.twitter.com/1.1/blocks/create.json';
60-
$requestMethod = 'POST';
65+
```php
66+
$url = 'https://api.twitter.com/1.1/blocks/create.json';
67+
$requestMethod = 'POST';
68+
```
6169

6270
#### Choose POST fields ####
6371

64-
$postfields = array(
65-
'screen_name' => 'usernameToBlock',
66-
'skip_status' => '1'
67-
);
72+
```php
73+
$postfields = array(
74+
'screen_name' => 'usernameToBlock',
75+
'skip_status' => '1'
76+
);
77+
```
6878

6979
#### Perform the request! ####
7080

71-
$twitter = new TwitterAPIExchange($settings);
72-
echo $twitter->buildOauth($url, $requestMethod)
73-
->setPostfields($postfields)
74-
->performRequest();
81+
```php
82+
$twitter = new TwitterAPIExchange($settings);
83+
echo $twitter->buildOauth($url, $requestMethod)
84+
->setPostfields($postfields)
85+
->performRequest();
86+
```
7587

7688
GET Request Example
77-
----------------
89+
-------------------
7890

7991
Set the GET field BEFORE calling buildOauth(); and everything else is the same:
8092

81-
$url = 'https://api.twitter.com/1.1/followers/ids.json';
82-
$getfield = '?screen_name=J7mbo';
83-
$requestMethod = 'GET';
93+
```php
94+
$url = 'https://api.twitter.com/1.1/followers/ids.json';
95+
$getfield = '?screen_name=J7mbo';
96+
$requestMethod = 'GET';
8497

85-
$twitter = new TwitterAPIExchange($settings);
86-
echo $twitter->setGetfield($getfield)
87-
->buildOauth($url, $requestMethod)
88-
->performRequest();
98+
$twitter = new TwitterAPIExchange($settings);
99+
echo $twitter->setGetfield($getfield)
100+
->buildOauth($url, $requestMethod)
101+
->performRequest();
102+
```
89103

90104
That is it! Really simple, works great with the 1.1 API. Thanks to @lackovic10 and @rivers on SO!

composer.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
"ext-curl": "*"
44
},
55
"require-dev": {
6-
"phpunit/phpunit": "4.5.1"
6+
"phpunit/phpunit": "~4.5,>=4.5.1"
77
},
88
"name": "j7mbo/twitter-api-php",
99
"description": "Simple PHP Wrapper for Twitter API v1.1 calls",
10-
"version": "1.0.0",
1110
"type": "library",
1211
"keywords": [
1312
"twitter",
@@ -24,5 +23,10 @@
2423
],
2524
"autoload": {
2625
"files": ["TwitterAPIExchange.php"]
26+
},
27+
"extra": {
28+
"branch-alias": {
29+
"dev-master": "1.0-dev"
30+
}
2731
}
2832
}

0 commit comments

Comments
 (0)