Exemplo n.º 1
0
void LoadPage::fetchPage(const QString & url) {
	qDebug() << "LoadPage::fetchPage:" << url;
	qDebug() << "LoadPage::fetchPage: user agent:" << userAgent();

	QNetworkRequest req(url);
	req.setRawHeader("User-Agent", userAgent().toLatin1());
	req.setRawHeader("Accept-Language", "en-us,en;q=0.5");
	reply = manager->get(req);
	connect(reply, SIGNAL(finished()), this, SLOT(gotResponse()));
}
Exemplo n.º 2
0
/**
 *   Starts a search
 *   @param query the search query to run against people search
 *   @param perPage the number of people per page to retrieve. Maxiumum of 20 allowed per page.
 *   @param page specifies the page of results to retrieve
 *   @param includeEntities when set to true each tweet will include a node called "entities".
 */
void QTweetUserSearch::search(const QString &query,
                              int perPage,
                              int page,
                              bool includeEntities)
{
    if (!isAuthenticationEnabled()) {
        qCritical("Needs authentication to be enabled");
        return;
    }

    QUrl url("https://api.twitter.com/1.1/users/search.json");

    url.addQueryItem("q", query);

    if (perPage)
        url.addQueryItem("per_page", QString::number(perPage));

    if (page)
        url.addQueryItem("page", QString::number(page));

    if (includeEntities)
        url.addQueryItem("include_entities", "true");

    QNetworkRequest req(url);
    req.setRawHeader("User-Agent", userAgent());
    QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET);
    req.setRawHeader(AUTH_HEADER, oauthHeader);

    QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req);
    connect(reply, SIGNAL(finished()), this, SLOT(reply()));
}
Exemplo n.º 3
0
/** Creates list
 *  @param user user id
 *  @param name the name of the list
 *  @param mode true for public list, false for private list
 *  @param description the description to give the list.
 */
void QTweetListCreate::create(qint64 user,
                              const QString &name,
                              bool mode,
                              const QString &description)
{
    if (!isAuthenticationEnabled()) {
        qCritical("Needs authentication to be enabled");
        return;
    }

    QUrl url(QString("https://api.twitter.com/1/%1/lists.json").arg(user));

    QUrl urlQuery(url);

    urlQuery.addEncodedQueryItem("name", QUrl::toPercentEncoding(name));

    if (!mode)
        urlQuery.addQueryItem("mode", "private");

    if (!description.isEmpty())
        urlQuery.addEncodedQueryItem("description", QUrl::toPercentEncoding(description));

    QNetworkRequest req(url);
    req.setRawHeader("User-Agent", userAgent());
    QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(urlQuery, OAuth::POST);
    req.setRawHeader(AUTH_HEADER, oauthHeader);
    req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");

    QByteArray postBody = urlQuery.toEncoded(QUrl::RemoveScheme | QUrl::RemoveAuthority | QUrl::RemovePath);
    postBody.remove(0, 1);

    QNetworkReply *reply = oauthTwitter()->networkAccessManager()->post(req, postBody);
    connect(reply, SIGNAL(finished()), this, SLOT(reply()));
}
 QString userAgentForUrl(const QUrl & url) const
 {
     QString userAgent(QWebPage::userAgentForUrl(url) + QString(" Utopia/" UTOPIA_VERSION_PATCH_STRING));
     userAgent.replace(" Safari", " Mobile Safari");
     //qDebug() << "userAgent:" << userAgent;
     return userAgent;
 }
/**
 *   save a search query
 */
void QTweetSaveSearchQuery::save(const QString& query)
{
    if (!isAuthenticationEnabled()) {
        qCritical("Needs authentication to be enabled");
        return;
    }

    QUrl url("https://api.twitter.com/1.1/saved_searches/create.json");

    QUrl urlQuery(url);

    urlQuery.addQueryItem("query", query);


    QNetworkRequest req(url);
    req.setRawHeader("User-Agent", userAgent());
    QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(urlQuery, OAuth::POST);
    req.setRawHeader(AUTH_HEADER, oauthHeader);
    req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");

    QByteArray postBody = urlQuery.toEncoded(QUrl::RemoveScheme | QUrl::RemoveAuthority | QUrl::RemovePath);
    postBody.remove(0, 1);

    QNetworkReply *reply = oauthTwitter()->networkAccessManager()->post(req, postBody);
    connect(reply, SIGNAL(finished()), this, SLOT(reply()));
}
/**
 * @param user user id
 * @param list list id
 * @param cursor breaks the results into pages.
                This is recommended for users who are following many users.
                Provide a value of -1 to begin paging.
                Provide values as returned in the signal nextCursor and prevCursor to page back and forth in the list.
 * @param includeEntities When set to true tweet will include a node called "entities,"
 */
void QTweetListGetMembers::get(qint64 user,
                               qint64 list,
                               const QString &cursor,
                               bool includeEntities)
{
    if (!isAuthenticationEnabled()) {
        qCritical("Needs authentication to be enabled");
        return;
    }

    QUrl url(QString("https://api.twitter.com/1/%1/%2/members.json").arg(user).arg(list));

    if (!cursor.isEmpty())
        url.addQueryItem("cursor", cursor);

    if (includeEntities)
        url.addQueryItem("include_entities", "true");

    QNetworkRequest req(url);
    req.setRawHeader("User-Agent", userAgent());
    QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET);
    req.setRawHeader(AUTH_HEADER, oauthHeader);

    QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req);
    connect(reply, SIGNAL(finished()), this, SLOT(reply()));
}
Exemplo n.º 7
0
bool WebPage::platformHasLocalDataForURL(const WebCore::KURL& url)
{
#if USE(CFNETWORK)
    RetainPtr<CFURLRef> cfURL(AdoptCF, url.createCFURL());
    RetainPtr<CFMutableURLRequestRef> request(AdoptCF, CFURLRequestCreateMutable(0, cfURL.get(), kCFURLRequestCachePolicyReloadIgnoringCache, 60, 0));
    
    RetainPtr<CFStringRef> userAgent(AdoptCF, userAgent().createCFString());
    CFURLRequestSetHTTPHeaderFieldValue(request.get(), CFSTR("User-Agent"), userAgent.get());

    RetainPtr<CFURLCacheRef> cache(AdoptCF, CFURLCacheCopySharedURLCache());

    RetainPtr<CFCachedURLResponseRef> response(AdoptCF, CFURLCacheCopyResponseForRequest(cache.get(), request.get()));    
    return response;
#else
    return false;
#endif
}
Exemplo n.º 8
0
void UpdateApplication::resetRequest()
// ----------------------------------------------------------------------------
//    Initialize HTTP request
// ----------------------------------------------------------------------------
{
    request = QNetworkRequest();
    request.setRawHeader("User-Agent", userAgent().toUtf8());
}
Exemplo n.º 9
0
String NavigatorBase::appVersion() const
{
    // Version is everything in the user agent string past the "Mozilla/" prefix.
    const String& agent = userAgent();
    /// M: For CU specific UserAgent which not start with "Mozilla/" @{
    if (!agent.startsWith("Mozilla/"))
        return String("5.0 ") + agent;
    else
        /// }@
        return agent.substring(agent.find('/') + 1);
}
Exemplo n.º 10
0
/**
 *   Posts a tweet
 *   @param status text of the status update
 *   @param inReplyToStatus ID of a existing tweet is in reply to
 *   @param latLong latitude and longitude
 *   @param placeid a place in the world (use reverse geocoding)
 *   @param displayCoordinates whether or not to put a exact coordinates a tweet has been sent from
 */
void QTweetStatusUpdate::post(const QString &status,
                              qint64 inReplyToStatus,
                              const QTweetGeoCoord& latLong,
                              const QString &placeid,
                              bool displayCoordinates,
                              bool trimUser,
                              bool includeEntities)
{
    if (!isAuthenticationEnabled()) {
        qCritical("Needs authentication to be enabled");
        return;
    }

    QUrl url("https://api.twitter.com/1.1/statuses/update.json");

    QUrl urlQuery("https://api.twitter.com/1.1/statuses/update.json");

    urlQuery.addEncodedQueryItem("status", QUrl::toPercentEncoding(status));

    if (inReplyToStatus != 0)
        urlQuery.addQueryItem("in_reply_to_status_id", QString::number(inReplyToStatus));

    if (latLong.isValid()) {
        urlQuery.addQueryItem("lat", QString::number(latLong.latitude()));
        urlQuery.addQueryItem("long", QString::number(latLong.longitude()));
    }

    if (!placeid.isEmpty())
        urlQuery.addQueryItem("place_id", placeid);

    if (displayCoordinates)
        urlQuery.addQueryItem("display_coordinates", "true");

    if (trimUser)
        urlQuery.addQueryItem("trim_user", "true");

    if (includeEntities)
        urlQuery.addQueryItem("include_entities", "true");

    QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(urlQuery, OAuth::POST);
    QNetworkRequest req(url);
    req.setRawHeader(AUTH_HEADER, oauthHeader);
    req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
    req.setRawHeader("User-Agent", userAgent());
    //build status post array
    QByteArray statusPost = urlQuery.toEncoded(QUrl::RemoveScheme | QUrl::RemoveAuthority | QUrl::RemovePath);

    //remove '?'
    statusPost.remove(0, 1);

    QNetworkReply *reply = oauthTwitter()->networkAccessManager()->post(req, statusPost);
    connect(reply, SIGNAL(finished()), this, SLOT(reply()));
}
Exemplo n.º 11
0
    void isAncient(x0::HttpRequest *r, const x0::FlowParams& args, x0::FlowValue& result)
    {
        x0::BufferRef userAgent(r->requestHeader("User-Agent"));

        for (auto& ancient: ancients_) {
            if (userAgent.find(ancient.c_str()) != x0::BufferRef::npos) {
                result.set(true);
                return;
            }
        }
        result.set(false);
    }
Exemplo n.º 12
0
QNetworkRequest getRequest(const QString& urlString, QNetworkReply* referer)
{
	ProcessedUrl url = processUrl(urlString);

	QNetworkRequest result(url.url);
	result.setRawHeader("User-Agent", userAgent().toUtf8());

	if (referer) {
		result.setRawHeader("Referer", referer->url().toEncoded());
	}

	return result;
}
Exemplo n.º 13
0
/**
 *  Starts fetching information about place
 *  @param placeid a place in the world. These ID's can be retrieved from QTweetGeoReverseGeoCode
 */
void QTweetGeoPlaceID::get(const QString &placeid)
{
    QUrl url(QString("https://api.twitter.com/1/geo/id/%1.json").arg(placeid));

    QNetworkRequest req(url);
    req.setRawHeader("User-Agent", userAgent());
    if (isAuthenticationEnabled()) {
        QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET);
        req.setRawHeader(AUTH_HEADER, oauthHeader);
    }

    QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req);
    connect(reply, SIGNAL(finished()), this, SLOT(reply()));
}
Exemplo n.º 14
0
void FunkytownConfigDialog::writeSettings()
{
   mpProxyWidget->writeSettings();

   QString userAgent( Settings::value( Settings::FunkytownUserAgent ) );
   if( userAgent.isEmpty() )
   {
      userAgent = "Shockwave Flash";
      Settings::setValue( Settings::FunkytownUserAgent, userAgent );
   }
   Settings::setValue( Settings::FunkytownOverwrite, mpOverwrite->isChecked() );
   Settings::setValue( Settings::FunkytownCoverArt, mpCoverArt->isChecked() );
   Settings::setValue( Settings::FunkytownTollKeep, mpTollKeep->isChecked() );
}
/**
 *  Starts checking rate limit status
 *  @remarks Should be emiting rateLimitInfo signal after finishing
 */
void QTweetAccountRateLimitStatus::check()
{
    QUrl url("https://api.twitter.com/1/account/rate_limit_status.json");

    QNetworkRequest req(url);
    req.setRawHeader("User-Agent", userAgent());

    if (isAuthenticationEnabled()) {
        QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET);
        req.setRawHeader(AUTH_HEADER, oauthHeader);
    }

    QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req);
    connect(reply, SIGNAL(finished()), this, SLOT(reply()));
}
Exemplo n.º 16
0
TBool CTestTransaction::SetUserAgentL(RHTTPHeaders &aHeaders, RStringPool &aStrPool)
	{
	//	get the DEFINE for UserAgent
	TBuf8<KMaxUserAgentSize> userAgentBuf;
	userAgentBuf.Copy(Machine()->GetDefine(KITHUserAgent));

	TInt iLen = userAgentBuf.Length();
	//	assign the selection
	RStringF agent = (iLen == 0) ? aStrPool.OpenFStringL(KUserAgent) : aStrPool.OpenFStringL(userAgentBuf);
	THTTPHdrVal userAgent(agent);
	aHeaders.SetFieldL(aStrPool.StringF(HTTP::EUserAgent, RHTTPSession::GetTable()), userAgent);
	agent.Close();

	return ETrue;
	}
/**
 *  Start geo reversing
 *  @param latLong latitutde and longitude
 *  @param accuracy a hint on the "region" in which to search in meters
 *  @param granularity minimal granularity of place types to return
 *  @param maxResults hint as to the number of results to return
 */
void QTweetGeoReverseGeoCode::getPlaces(const QTweetGeoCoord& latLong,
                                        int accuracy,
                                        QTweetPlace::Type granularity,
                                        int maxResults)
{
    QUrl url("https://api.twitter.com/1.1/geo/reverse_geocode.json");

    url.addQueryItem("lat", QString::number(latLong.latitude()));
    url.addQueryItem("long", QString::number(latLong.longitude()));

    if (accuracy != 0)
        url.addQueryItem("accuracy", QString::number(accuracy));

    switch (granularity) {
    case QTweetPlace::Poi:
        url.addQueryItem("granularity", "poi");
        break;
    case QTweetPlace::Neighborhood:
        url.addQueryItem("granularity", "neighborhood");
        break;
    case QTweetPlace::City:
        url.addQueryItem("granularity", "city");
        break;
    case QTweetPlace::Admin:
        url.addQueryItem("granularity", "admin");
        break;
    case QTweetPlace::Country:
        url.addQueryItem("granularity", "country");
        break;
    default:
        ;
    }

    if (maxResults != 0)
        url.addQueryItem("max_results", QString::number(maxResults));

    QNetworkRequest req(url);
    req.setRawHeader("User-Agent", userAgent());
    if (isAuthenticationEnabled()) {
        QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET);
        req.setRawHeader(AUTH_HEADER, oauthHeader);
    }

    QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req);
    connect(reply, SIGNAL(finished()), this, SLOT(reply()));
}
void RESTFriendshipExists::fetch(const qint64& userid1, const qint64& userid2)
{
	QUrl url("https://api.twitter.com/1/friendships/exists.json?");
	url.addQueryItem("user_id_a", QString::number(userid1));
	url.addQueryItem("user_id_b", QString::number(userid2));

	//fprintf(stderr, "fetchForUrl  %s \n", url.toString().toStdString().c_str());
	QNetworkRequest req(url);
	req.setRawHeader("User-Agent", userAgent());
	if (isAuthenticationEnabled()) {
		QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET);
		req.setRawHeader(AUTH_HEADER, oauthHeader);
	}

	QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req);
	connect(reply, SIGNAL(finished()), this, SLOT(reply()));
}
Exemplo n.º 19
0
/**
 *  Starts fetching one page of id's
 *  @param screenName the screen name of the user for whom to return results for.
 *  @param cursor use from signal response nextCursor and prevCursor to allow paging back and forth
 */
void QTweetFollowersID::fetch(const QString &screenName, const QString &cursor)
{
    QUrl url("https://api.twitter.com/1/followers/ids.json");

    url.addQueryItem("screen_name", screenName);
    url.addQueryItem("cursor", cursor);

    QNetworkRequest req(url);
    req.setRawHeader("User-Agent", userAgent());
    if (isAuthenticationEnabled()) {
        QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET);
        req.setRawHeader(AUTH_HEADER, oauthHeader);
    }

    QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req);
    connect(reply, SIGNAL(finished()), this, SLOT(reply()));
}
Exemplo n.º 20
0
// adapted from afisha-cinema/httphelpers.cpp
int httpGet(QHttp* http, const QString& urlString)
{
	ProcessedUrl url = processUrl(urlString);

	QHttpRequestHeader header("GET", url.fullUri);
	header.setValue("User-Agent", userAgent());
	header.setValue("Host", QString("%1:%2").arg(url.url.host(), url.url.port()));
	header.setValue("Accept-Language", "en-us");
	header.setValue("Accept", "*/*");

	QByteArray content;
	header.setContentLength(content.length());

	Q_ASSERT(url.url.scheme() == "https");
	http->setHost(url.url.host(), QHttp::ConnectionModeHttps,
	              443);
	return http->request(header, content);
}
/**
 *   @param user user id owner of the list
 *   @param list list id
 */
void QTweetListSubscribe::follow(qint64 user, qint64 list)
{
    if (!isAuthenticationEnabled()) {
        qCritical("Needs authentication to be enabled");
        return;
    }

    QUrl url(QString("https://api.twitter.com/1/%1/%2/subscribers.json").arg(user).arg(list));

    QNetworkRequest req(url);
    req.setRawHeader("User-Agent", userAgent());
    QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::POST);
    req.setRawHeader(AUTH_HEADER, oauthHeader);
    req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");

    QNetworkReply *reply = oauthTwitter()->networkAccessManager()->post(req, QByteArray());
    connect(reply, SIGNAL(finished()), this, SLOT(reply()));
}
Exemplo n.º 22
0
/**
 *   Starts fetching
 *   @param userid user ID
 *   @param includeEntities when set to true, each tweet will include a node called "entities"
 */
void QTweetUserShow::fetch(const QString &screenName, bool includeEntities)
{
    QUrl url("https://api.twitter.com/1.1/users/show.json");

    url.addQueryItem("screen_name", screenName);

    if (includeEntities)
        url.addQueryItem("include_entities", "true");

    QNetworkRequest req(url);
    req.setRawHeader("User-Agent", userAgent());
    if (isAuthenticationEnabled()) {
        QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET);
        req.setRawHeader(AUTH_HEADER, oauthHeader);
    }

    QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req);
    connect(reply, SIGNAL(finished()), this, SLOT(reply()));
}
Exemplo n.º 23
0
void KisGmicUpdater::start()
{
    QUrl url(m_url);
    QNetworkRequest request(url);

    QString userAgent("org.krita.gmic/");

    QString version = QString("%0.%1.%2.%3").arg(gmic_version/1000).arg((gmic_version/100)%10).arg((gmic_version/10)%10).arg(gmic_version%10);

    userAgent.append(version);
    dbgPlugins << "userAgent" << userAgent.toLatin1();

    request.setRawHeader("User-Agent", userAgent.toLatin1());

    QNetworkReply * getReply = m_manager.get(request);

    connect(getReply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(reportProgress(qint64,qint64)));
    connect(getReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(slotError(QNetworkReply::NetworkError)));
}
Exemplo n.º 24
0
UpdateApplication::UpdateApplication()
// ----------------------------------------------------------------------------
//    Constructor
// ----------------------------------------------------------------------------
    : state(Idle), file(NULL), progress(NULL),
      dialogTitle(QString(tr("Tao3D Update"))),
      downloadIcon(loadIcon(":/images/download.png")),
      checkmarkIcon(loadIcon(":images/checkmark.png")),
      connectionErrorIcon(loadIcon(":/images/not_connected.png")),
      reply(NULL), manager(NULL), code(-1)
{
    // download.png from http://www.iconfinder.com/icondetails/2085/128
    // Author: Alexandre Moore
    // License: LGPL
    //
    // checkmark.png from http://www.iconfinder.com/icondetails/3207/128
    // Author: Everaldo Coelho
    // License: LGPL

    // not_connected.png is a merge from:
    //
    // - Red cross from http://www.iconfinder.com/icondetails/3206/128
    //   Author: Everaldo Coelho
    //   License: LGPL
    // - Earth from http://www.iconfinder.com/icondetails/17829/128
    //   Author: Everaldo Coelho
    //   License: LGPL

    resetRequest();

    progress = new QProgressDialog(TaoApp->windowWidget());
    progress->setFixedSize(500, 100);
    connect(progress, SIGNAL(canceled()),
            this,     SLOT(cancel()));
    progress->setWindowTitle(dialogTitle);

    IFTRACE(update)
    debug() << "Current version: edition='" << +edition
            << "' version=" << version
            << " target='" << +target << "'"
            << " User-Agent='" << +userAgent() << "'\n";
}
/**
 *   @param id the ID of the direct message to delete.
 *   @param includeEntities When set to true, each tweet will include a node called "entities,"
 */
void QTweetDirectMessageDestroy::destroyMessage(qint64 id, bool includeEntities)
{
    if (!isAuthenticationEnabled()) {
        qCritical("Needs authentication to be enabled");
        return;
    }

    QUrl url(QString("https://api.twitter.com/1/direct_messages/destroy/%1.json").arg(id));

    if (includeEntities)
        url.addQueryItem("include_entities", "true");

    QNetworkRequest req(url);
    req.setRawHeader("User-Agent", userAgent());
    QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::DELETE);
    req.setRawHeader(AUTH_HEADER, oauthHeader);

    QNetworkReply *reply = oauthTwitter()->networkAccessManager()->deleteResource(req);
    connect(reply, SIGNAL(finished()), this, SLOT(reply()));
}
Exemplo n.º 26
0
QNetworkRequest postFileRequest(const QString& urlString, const QString& fieldName, const QString& fileName, const QByteArray& fileData, QByteArray* postData)
{
	QString boundary = getBoundaryString(fileData);

	postData->append("--" + boundary + "\r\n");
	postData->append("Content-Disposition: form-data; name=\"" + TextUtil::escape(fieldName) +
	                "\"; filename=\"" + TextUtil::escape(fileName.toUtf8()) + "\"\r\n");
	postData->append("Content-Type: application/octet-stream\r\n");
	postData->append("\r\n");
	postData->append(fileData);
	postData->append("\r\n--" + boundary + "--\r\n");

	ProcessedUrl url = processUrl(urlString);

	QNetworkRequest result(url.url);
	result.setRawHeader("User-Agent", userAgent().toUtf8());
	result.setRawHeader("Content-Type", "multipart/form-data, boundary=" + boundary.toLatin1());
	result.setRawHeader("Content-Length", QString::number(postData->length()).toUtf8());
	return result;
}
Exemplo n.º 27
0
/**
 *   Starts fetching retweets to user
 *   @param sinceid Fetches tweets with ID greater (more recent) then sinceid
 *   @param maxid Fetches tweets with ID less (older) then maxid
 *   @param count Number of tweets to fetch (up to 200)
 *   @param page Page number
 *   @remarks Setting parameter to default value, will not be put in the query
 */
void QTweetRetweetToMe::fetch(qint64 sinceid,
                              qint64 maxid,
                              int count,
                              int page,
                              bool trimUser,
                              bool includeEntities)
{
    if (!isAuthenticationEnabled()) {
        qCritical("Needs authentication to be enabled");
        return;
    }

    QUrl url("https://api.twitter.com/1/statuses/retweeted_to_me.json");

    if (sinceid != 0)
        url.addQueryItem("since_id", QString::number(sinceid));

    if (maxid != 0)
        url.addQueryItem("max_id", QString::number(maxid));

    if (count != 0)
        url.addQueryItem("count", QString::number(count));

    if (page != 0)
        url.addQueryItem("page", QString::number(page));

    if (trimUser)
        url.addQueryItem("trim_user", "true");

    if (includeEntities)
        url.addQueryItem("include_entities", "true");

    QNetworkRequest req(url);
    req.setRawHeader("User-Agent", userAgent());
    QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET);
    req.setRawHeader(AUTH_HEADER, oauthHeader);

    QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req);
    connect(reply, SIGNAL(finished()), this, SLOT(reply()));
}
/**
 *  Unfollows the specified user
 *  @param screenName screen name to unfollow
 *  @param includeEntities when set totrue, each tweet will include a node called "entities,".
 */
void QTweetFriendshipDestroy::unfollow(const QString &screenName, bool includeEntities)
{
    if (!isAuthenticationEnabled()) {
        qCritical("Needs authentication to be enabled");
        return;
    }

    QUrl url("https://api.twitter.com/1/friendships/destroy.json");

    url.addQueryItem("screen_name", screenName);

    if (includeEntities)
        url.addQueryItem("include_entities", "true");

    QNetworkRequest req(url);
    req.setRawHeader("User-Agent", userAgent());
    QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::DELETE);
    req.setRawHeader(AUTH_HEADER, oauthHeader);

    QNetworkReply *reply = oauthTwitter()->networkAccessManager()->deleteResource(req);
    connect(reply, SIGNAL(finished()), this, SLOT(reply()));
}
Exemplo n.º 29
0
/**
 *   Starts fetching user followers list
 *   @param woeid
 *   @param exclusion
 */
void RESTLocalTrends::fetch(const double latitude, const double longitude, qint64 woeid,
					   const QString &exclusion)
{
	QUrl url("https://api.twitter.com/1.1/trends/closest.json?");

    url.addQueryItem("lat", QString::number(latitude));
    url.addQueryItem("long", QString::number(longitude));

    if (!exclusion.isEmpty()) {
        url.addQueryItem("exclude", exclusion);
    }

    QNetworkRequest req(url);
    //fprintf(stderr, "url is: %s \n", url.toString().toStdString().c_str());
    req.setRawHeader("User-Agent", userAgent());
    if (isAuthenticationEnabled()) {
        QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(url, OAuth::GET);
        req.setRawHeader(AUTH_HEADER, oauthHeader);
    }

    QNetworkReply *reply = oauthTwitter()->networkAccessManager()->get(req);
    connect(reply, SIGNAL(finished()), this, SLOT(reply()));
}
Exemplo n.º 30
0
    void isModern(x0::HttpRequest *r, const x0::FlowParams& args, x0::FlowValue& result)
    {
        x0::BufferRef userAgent(r->requestHeader("User-Agent"));

        for (auto& modern: modern_) {
            std::size_t i = userAgent.find(modern.first.c_str());
            if (i == x0::BufferRef::npos)
                continue;

            i += modern.first.size();
            if (userAgent[i] != '/') // expecting '/' as delimiter
                continue;

            float version = userAgent.ref(++i).toFloat();

            if (version < modern.second)
                continue;

            result.set(true);
            return;
        }
        result.set(false);
    }