Automatically publish to Twitter from the PHP website

Asked

Viewed 1,520 times

8

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

On Twitter will appear:

  • the name of the product
  • 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 struggling.

What are the basic steps for using the Twitter API?

  • 1

    It may seem too broad, but for those who start it it can be a good help a good response

  • 4

    The way I see it, he needs a kickoff. What is a doubt and the answer can be very simple as transcribing some of the https://dev.twitter.com/docs/api/1.1/post/statuses/update which is the tutorial he wants

  • 1

    Try to explain what the difficulty is, if you have any code edit the question and put it.

  • 2

    Discussion in META on this question: http://meta.pt.stackoverflow.com/q/1344/7210

1 answer

10


Using the Restapi of Twitter you must 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, usually up to 140 characters. Do URL encoding as needed. Encapsulate with a t.co link can affect character count.

    There are some special commands in this field for which we should be aware. 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 this.

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

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

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

    Sample Values: 37,7821120598956

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

    Sample Values: -122,400612831116

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

    Sample Values: df51dec6f4ee2b2c

  • display_coordinates optional
    Whether or not to place a pin at the exact coordinate from which a tweet was sent.

    Sample Values: true

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

    Sample Values: true

Browser other questions tagged

You are not signed in. Login or sign up in order to post.