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.”
Related
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)
I am using tmhoauth library to build a small twitter app demo. Everything works fine like retrieving tweets, making searches etc. But when I try to retrieve trending topics using woeid, I get a 404 - This page does not exist error. I have tried different woeids'.
I will be grateful if someone could point what I am doing wrong.
here is my code.
public function trends1(){
require 'tmhOAuth.php';
require 'tmhUtilities.php';
$tmhOAuth = new tmhOAuth(array(
'consumer_key' => $this->consumerkey,
'consumer_secret' => $this->consumersecret,
'user_token' => $this->accesstoken,
'user_secret' => $this->accesstokensecret,
'curl_ssl_verifypeer' => false
));
$args = array('id' => '23424975');
$code = $tmhOAuth->request("GET", $tmhOAuth->url("https://api.twitter.com/1.1/trends/place.json"), $args);
print $code;
$res = $tmhOAuth->response['response'];
$trends = json_decode($res, true);
return $trends;
}
Try removing https://api.twitter.com/ from the URL. I was getting a 404 as well until I removed that segment of the URL and am now getting a 200 response code.
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
I am using facebook api to get backup of the facebook photos using access_token and fql.
Using fql I got the list of albums of the user
$client = new Facebook(array('appId' => 'xxxx', 'secret' => 'xxxxxx'));
$fql_albums = "SELECT aid,name from album where owner=$user_Id";
$albumId = $client->api(array(
'method' => 'fql.query',
'access_token' => $user_access_token,
'query' => $fql_albums,
));
After getting this list I run a query to get all the photos in the album and then download that album and then moves to the next album.
It only download 2 albums and then gets an error as shown below
( ! ) Fatal error: Uncaught CurlException: 28: SSL connection timeout
thrown in
D:\wamp\www\FrostBox1.0\Facebook\FaceBookConnect\facebook-php-sdk\src\base_facebook.php
on line 759
What could I be doing wrong?
For me, the solution was adding
$opts[CURLOPT_SSLVERSION] = 3;
before
curl_setopt_array($ch, $opts);
in base_facebook.php
Thanks to:
https://developers.facebook.com/bugs/213367445404472/?browse=search_4eeccca164bbe6357503363
open base_facebook.php
find CURLOPT_CONNECTTIMEOUT => 10
change it to CURLOPT_CONNECTTIMEOUT => 30
That's it!
I solved it by adding:
CURLOPT_SSLVERSION => 3,
after the line:
CURLOPT_USERAGENT => 'facebook-php-3.1',
at - base_facebook.php
(it will make curl to use SSLv3)
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.