Post to multiple twitter accounts PHP - php

i HAVE read many Tutorials on posting to twitter using OAuth like here but i am still unclear on some things.
My requirements is to tweet through multiple accounts for each of which i have a username/password.
Is this possible ? If yes then how do i do it?
I am confused how to get the 4secret keys required for each user account that i have.

1. PHP Class: https://github.com/themattharris/tmhOAuth
2. PHP Function
function tweet($status, $consumer_key, $consumer_secret, $user_token, $user_secret){
include("class.twitter.php");
$tmhOAuth = new tmhOAuth(array(
'consumer_key'=> $consumer_key,
'consumer_secret' => $consumer_secret,
'user_token' => $user_token,
'user_secret' => $user_secret,
));
$tmhOAuth->request('POST', $tmhOAuth->url('1/statuses/update'), array(
'status' => $status
));
}
3. https://dev.twitter.com/apps/new (register an app, get keys foreach account)
4. tweet("yay!", ...);
5. goto 4 but with different keys

Read up on Twitter's authentication scheme, and then have a look at some libraries.

Related

bigcommerce rest api v3 php

I have to implement bigcommerce API integration with PHP
and I am trying to use the official library from https://github.com/bigcommerce/bigcommerce-api-php
and I am not even able to start step 1 here.
Issues:
Basic Auth method
Bigcommerce::configure(array(
'store_url' => 'https://store.mybigcommerce.com',
'username' => 'admin',
'api_key' => 'd81aada4xc34xx3e18f0xxxx7f36ca'
));
So the question here is how to get a username? bigcommerece user only created using email address so how to get username here?
OAuth method
In order to obtain the auth_token you would consume Bigcommerce::getAuthToken method
$object = new \stdClass();
$object->client_id = 'xxxxxx';
$object->client_secret = 'xxxxx;
$object->redirect_uri = 'https://app.com/redirect';
$object->code = $request->get('code');
$object->context = $request->get('context');
$object->scope = $request->get('scope');
$authTokenResponse = Bigcommerce::getAuthToken($object);
Bigcommerce::configure(array(
'client_id' => 'xxxxxxxx',
'auth_token' => $authTokenResponse->access_token,
'store_hash' => 'xxxxxxx'
));
here the question is what is the $request variable? also, redirect_uri is the bigcommerce store URL or my site URL?
Please can anyone help to get started with this?
It's because that library is a bit out of date with how api accounts are managed. For the basic auth you would use "legacy accounts". You can just use the OAuth method without the oAuth flow (assuming you're trying to connect to your own store, not create an app).
Just the following will work:
Bigcommerce::configure(array(
'client_id' => 'client-id',
'auth_token' => 'access-token',
'store_hash' => 'store-hash'
));
You should get these after creating a user in the dashboard (you can ignore the secret for this use case)

What is 410 error status in Twitter API?

I have been trying to make an API to retweet using status id, but I got a 410 status error. I searched how to make a retweet and I found the following code, but I face the mentioned error:
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
require 'tmhOAuth.php';
$tmhOAuth = new tmhOAuth(array(
'consumer_key' => $consumerKey,
'consumer_secret' => $consumerSecret,
'user_token' => $oAuthToken,
'user_secret' => $oAuthSecret,
'curl_timeout' => 60,
'curl_ssl_verifypeer' => 0
));
$code = $tmhOAuth->request('POST', $tmhOAuth->url('1/statuses/retweet/'),
array('id' => '505041593686974464' ));
echo $code;
?>
How can I retweet in Twitter using the tmhOAuth.php class?
Note: I already created an app to post text and images to my Twitter using the tmhOAuth.php class.
From dev.twitter.com:
This resource is gone. Used to indicate that an API endpoint has been
turned off. For example: “The Twitter REST API v1 will soon stop
functioning. Please migrate to API v1.1.”

Cannot post to page as app

Facebooks documentation is inadecuate, confusing at best.
I have created an app, I have created a page for my business. I want to post updates on that page from my website as my App using the php-sdk.
I had this working perfectly with other pages/sites but nothing seems to be working any more.
I require offline_access, so I have followed the new endpoint as suggested in their docs.
Sequence of obtaining access_token with longer expiry:
https://www.facebook.com/dialog/oauth?client_id={my_app_id}&redirect_uri=http://my_url.redirect/fb/fb_token.php&scope=publish_stream,offline_access,user_status,read_stream,email,user_groups,manage_pages&response_type=token
returned [TOKEN_1]
https://graph.facebook.com/oauth/access_token?client_id={my_app_id}&client_secret={my_app_secret}&grant_type=fb_exchange_token&fb_exchange_token=[TOKEN_1]
returned [ACCESS_TOKEN]
https://graph.facebook.com/me/accounts?access_token=[ACCESS_TOKEN]
returns list of my pages and apps and their relevant ids and access codes. This is where I got my final [DEFINITIVE_ACCESS_TOKEN] && [PAGE_ID]
$facebook = new Facebook(array(
'appId' => {my_app_id},
'secret' => {my_app_secret},
'cookie' => false,
'oauth' => true
));
try {
$attachment = array(
'access_token' => [DEFINITIVE_ACCESS_TOKEN],
'message' => {my_message},
'name' => {my_title},
'link' => {my_url},
'description' => {my_description},
'picture' => {my_image_url},
);
$publishStream = $facebook->api('/[PAGE_ID]/feed', 'POST', $attachment);
} catch (FacebookApiException $e) {
die($e);
}
This has returned an error message "OAuthException: (#200) Posts where the actor is a page cannot also include a target_id"
Where am I going wrong? Is there a tutorial of getting this to work perfectly anywhere or are we supposed to all be mind readers and guess how it is supposed to be done?
Thanks in advance for any help.
I have noticed you are using offline access
Offline access will no longer be available as of May 1, 2012.
See this
https://developers.facebook.com/roadmap/offline-access-removal/
Make sure you have handling for this.
~K

Using Zend GData library with OAuth and Picasa

I am trying to jus get something simple to work using the zend gdata library (for picasa) and some oauth credentials. So I have not idea if I'm passing in the OAuth stuff correctly, and whenever I go to create a gallery it fatals out trying to find '/Zend/Gdata/Photos/Extension/Title.php' which doesn't exist. Title does exist under App/Extension/Title.php. Not sure if it's related to how I'm adding in oauth, or if it's a problem with the autoloader....
$oauthOptions = array(
//'requestScheme' => Zend_Oauth::REQUEST_SCHEME_HEADER,
'version' => '2.0',
'signatureMethod' => 'HMAC-SHA1',
'consumerKey' => $CONSUMER_KEY,
'consumerSecret' => $CONSUMER_SECRET
);
$consumer = new Zend_Oauth_Consumer($oauthOptions);
$service = Zend_Gdata_Photos::AUTH_SERVICE_NAME;
$accessToken = new Zend_Oauth_Token_Access();
$accessToken->setToken('1/cIxUGEzJtHMt58coKjKEJBBRJV6KFinqpBXl8fX9OG_8');
$accessToken->setTokenSecret('Ykl2junbg06Uy5MncejtmKIy');
$httpClient = $accessToken->getHttpClient($oauthOptions);
$service = new Zend_Gdata_Photos($httpClient); //, "yourCompany-YourAppName-v1"
$entry = new Zend_Gdata_Photos_AlbumEntry();
$entry->setTitle($service->newTitle("test album"));
$service->insertAlbumEntry($entry);
http://www.dbjohn.com/2012/02/29/codeigniter-and-picasa-web-albums
try this

Post to Facebook Page Wall

I'm just trying to make PHP Connector to Facebook for posting wall posts on a Page.
So i'm not trying to post wall post to profile wall or anything else.
I've read some tutorials and manuals and i decided to use Facebook PHP-SDK (from Naitik Shah)
https://github.com/facebook/php-sdk/
I've created Facebook App to post wallposts through it. I received appId and api secret. I've added application permissions to my Page and tried example code
$facebook = new Facebook(array(
'appId' => 'my app id',
'secret' => 'my api secret',
'cookie' => false,
'domain' => 'domain.com'
));
domain.com => domain from which i'm sending api requests
next ->
$facebook->getSession();
$token = $facebook->getAccessToken();
$facebook->api('/123456789/feed', array(
'access_token' => $token,
'link' => 'http://www.example.com'
));
So i'm trying to post link on wall of page with id 123456789
The request goes through without warnings/errors but nothing is posted in right place and nothing is returned.
Thanks for any idea about this problem.
Used tutorials:
How do you post to the wall on a facebook page (not profile)
http://blog.theunical.com/facebook-integration/5-steps-to-publish-on-a-facebook-wall-using-php/
http://www.moskjis.com/other-platforms/publish-facebook-page-wall-from-your-site
http://tips4php.net/2010/12/automatic-post-to-facebook-from-php-script/
$facebook->api('/123456789/feed', 'post', array(
'access_token' => $token,
'link' => 'http://www.example.com'
));
Note the 'post' part.
If you look at the source for the API via the link you provided, you'll see:
protected function _graph($path, $method='GET', $params=array()) {
if (is_array($method) && empty($params)) {
$params = $method;
$method = 'GET';
}
When you don't have 'post' as the second argument and your array as the third, it goes a get
If you are getting authorisation errors, make sure you have included the following permission:
publish_stream
https://developers.facebook.com/docs/reference/api/post/

Categories