Automatically post to Twitter from the PHP site

8

I'm developing a backoffice in PHP. And every time the administrator adds a product, that product will automatically be published to Twitter.

On Twitter it will appear:

  • the product name
  • your image
  • and the link to the site

I had to do the same for Facebook, and so far so good. Now I'm trying for Twitter and I'm having difficulties.

What are the basic steps for using the Twitter API?

    
asked by anonymous 14.05.2014 / 12:20

1 answer

10

Using the RESTApi of Twitter You should perform a POST action on https://api.twitter.com/1.1/statuses/update.json with the following parameters:

  • status required
    The text of your status update, typically up to 140 characters. Make URL encoding as needed. Encapsulate with a t.co link can affect character counting.

    There are some special commands in this field that we should be aware of. For example, preceding a message with "D" or "M" and following it with a screen name can create a direct message to the user, if the relationship allows it.

  • in_reply_to_status_id optional
    The ID of an existing state that the update is in response to.

    Note: This parameter will be ignored unless the tweet author that this reference parameter is mentioned in the status text. Therefore, you should include @username , where username is the author of your referenced tweet, within the update.

  • lat optional
    The latitude of the place this tweet refers to. This parameter will be ignored unless it is within the range of -90.0 to 90.0 (North is positive) inclusive. It will also be ignored if it does not have a corresponding long parameter.

    Example values: 37,7821120598956

  • long optional
    The length of the location this tweet refers to. The valid range for longitude is -180.0 to 180.0 (East is positive), inclusive. This parameter will be ignored if outside this range, if it is not a number, if geo_enabled is disabled, or if it does not have a corresponding lat parameter.

    Example values: -122,400612831116

  • place_id optional
    A place in the world. These IDs can be retrieved from GET geo / reverse_geocode .

    Example values: df51dec6f4ee2b2c

  • display_coordinates optional
    Whether to place a pin in the exact coordinate from where a tweet was sent.

    Example values: true

  • trim_user optional
    When set to true , t or 1 , each tweet returned in the timeline will include a user object including only the numeric ID of the status authors. Omit this parameter to receive the full user object.

    Example values: true

14.05.2014 / 15:24